I have to print these decimal numbers in C++ . But first i need to understand this question mathematically .
I suppose $k$ could be arbitrary so we cannot rely on just computing $1/n$ within C++ code and extracting $i$-th decimal by multiplying with $10^i$ and taking $mod\ 10$.
We cannot do this for large $k$ because computer can store just a fixed amount of decimals (if some additional libraries are not used).
The simplest solution would be to just implement long division and print the decimal after each of $k$ steps.