How return decimal number with precision

Hii

My doubt is not related to this ques but in general 2 doubt

  1. how to we return decimal number from a function with precision of 6 digit

  2. how do we pass vector such that it is from a latter point in vector
    for eg in array we do like arr+10 for referencing to 10 place after but it does not work in case of vector i have passed vector by reference to a function

thanx in advance for the solution

Hey @gagangoyal674
To answer your first question
use this piece of code to control the precision

cout<<fixed<<setprecision(n)<<num;
where n is the precision you desire and num is the decimal number u wish to print.

To answer your second question
you can use the following code:
v.begin() returns a pointer to the first element of vector.
By this logic, v.begin() + 10 will point to the 11th element of the vector

I hope I was able to answer your queries. Please mark your doubt as resolved if I was able to answer your query.

In the first question i have to return it but this works fine when i need to just print it

I dont suppose there is a way to do that. In most of the questions, you will be required to output the answer upto a certain precision which can be done using the above method. So compute your answer normally and use the above piece of code to complete the rest of the question.

I hope I was able to answer your queries. Please mark your doubt as resolved if I was able to answer your query.