many times i have seen “answer should be correct to a relative error of 10^-6”.
when i used cout << setprecision(9) << val; i think it’s giving correct answer upto 9 decimal points but still i get WA and after adding cout << fixed; it gives AC!
my question is if “setprecision” is giving correct answer upto required decimal place then why do we need to print something like “6.00000000” why “6” is not accepted (as "cout << fixed; " is doing that only)?
float x=12/2;
cout<<fixed<<setprecision(9)<<x;
This will print 6 upto 9 decimal digits ,i.e,6.000000000 but if you will not fix it before
setprecision
then no decimal digit would be printed.