Similar topic is already discussed in the forum. But I have some different problem in following code:
double total;
cin >> total;
cout << fixed << setprecision(2) << total;
If I give input as 100.00
then program prints just 100
but not 100.00
How can I print 100.00
?
cout << fixed << setprecision(2) << total;
setprecision
specifies the minimum precision. So
cout << setprecision (2) << 1.2;
will print 1.2
fixed
says that there will be a fixed number of decimal digits after the decimal point
cout << setprecision (2) << fixed << 1.2;
will print 1.20