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/

7th Nov 2016, 2:26 AM
Infinity
Infinity - avatar
2 Answers
0
You can use printf("%.2f", 0.420202); to get just the two first decimal positions.
7th Nov 2016, 2:34 AM
Narciso Nuñez Arias
Narciso Nuñez Arias - avatar
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.
7th Nov 2016, 2:37 AM
kamal joshi
kamal joshi - avatar