0
How do I stop the execution of the program? In the program given below
this is a program to convert number with base 10 after the decimal part (0.xyz) to base 8. the program runs well but it doesn't stop when I input the value 0.53125 the output i want it 0.42 but the output i get is 0.420202 what changes should I make? link of the program http://www.sololearn.com/app/cplusplus/playground/c5l1398xrTor/
2 Answers
0
You can use printf("%.2f", 0.420202); to get just the two first decimal positions.
0
before displaying the value write:
cout.setf(ios::fixed);
cout.precision(2);
Also, include "iomanip" header file.
edit: you don't need iomanip header file.