How to display float value upto two decimal places in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to display float value upto two decimal places in c++?

Output format.

27th Jan 2017, 7:19 PM
Sher Khan
Sher Khan - avatar
3 Answers
+ 1
Use setprecision() function as cout << setprecision(2) << 23.456 .So the output is 23.46 because this function will round off. But in order to use it we have to include header file <iomanip.h> .
4th Feb 2017, 2:39 PM
Sher Khan
Sher Khan - avatar
0
Without a targeting language, you wouldn't have answer ^^
28th Jan 2017, 1:16 AM
visph
visph - avatar
0
h
12th Feb 2017, 12:03 AM
Harold Santos
Harold Santos - avatar