I am outputing float values... I guess by default they output with one decimal only. for example:
the output is:
12.3
my desired output is:
12.30
can anyone show me how to format the float so they're at 2 decimal points?
thank you!
A
I am outputing float values... I guess by default they output with one decimal only. for example:
the output is:
12.3
my desired output is:
12.30
can anyone show me how to format the float so they're at 2 decimal points?
thank you!
A
I guess by outputting you mean you are using the cout object in which case you can use setprecision(2) like this...
cout<<setprecision(2)<<myfloatvariable<<endl;
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
I get this error when I use <<setprecision(2) :
setprecision:undeclared identifier.......what does it mean?
thanks!
#include <iomanip.h>
int main()
{
cout << fixed << showpoint << setprecision(2);
cout << //output etc.
return 0;
}
I would be sooo helpless without the help!
Thank you!!!