0
I can't round accordingly
Am doing the code coach .. " Kalaidoscope" . When I run the program it says to round of upto 2 decimal places.. how can I round of it ..? Am inserting my code for reference.....please help https://code.sololearn.com/c64tJ8ZH3Il9/?ref=app
3 Answers
+ 3
One way to do it, is using C formatting:
printf("%.02f", price);
Here some more ideas:
https://www.geeksforgeeks.org/rounding-floating-point-number-two-decimal-places-c-c/
+ 3
For C++, this discussion might help: https://www.sololearn.com/Discuss/3197790/?ref=app
+ 3
cout << fixed << setprecision(2) << cost; //cpp way.. Include <iomanip> header file..
https://www.sololearn.com/Discuss/2486871/?ref=app