How to show the '0' after '.'?

Write here if you have problems with your C++ source code

Moderator: Board moderators

Post Reply
payton1
New poster
Posts: 5
Joined: Mon Oct 02, 2006 10:31 pm

How to show the '0' after '.'?

Post by payton1 »

How to show 3.00000 rather than 3?
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

Code: Select all

printf("%.5f\n", 3.0);
or

Code: Select all

cout.setf(ios::fixed);
cout.precision(5);
cout << 3.0 << endl;
payton1
New poster
Posts: 5
Joined: Mon Oct 02, 2006 10:31 pm

Post by payton1 »

thank you to solve it
Post Reply

Return to “C++”