double x;
input: 52.0
output: 52
why?
How to print 50.0 rather than 50 using double in c++
hi @namangarg31, in c++ the trailing zeros are ignored so you have to use setprecision
i.e the output format would be cout << fixed << setprecision(1) << x <<endl;
you can learn more about setprecision here:
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.