To get precision of n digits in decimal value.
First of all use the header #include<iomanip>
Write cout<<fixed; ///// to get the same precision of zeros also in decimal points.
Then cout<<setprecision(n); ----(A)
cout<<variable; //variable which you want with n decimal precision points.
Note: the value n should be in the decimal ranging of datatype. You can also use type casting to get more decimal point values.
Now all the values printed after the above statement A will have the same precision.
In order to disable the precision use the statement cout.unsetf (ios::fixed);
Comments
Post a Comment