Use -
cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint);
before printing floating point numbers.
More information can be found here .
You can also set the output accuracy with the following statement -
cout.precision(2);
or just with -
printf("%.2f", myfloat);
MD Sayem Ahmed
source share