I'm practicing with the following program and I cannot make it to show more decimal points other than 78.5, in other words I would like to show 78.5374984741 instead of just 78.5
Can someone be so kind and tell me how can I show the whole number when the program below runs?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
#include <cmath>
#include <iomanip>
usingnamespace std;
int main()
{
float radius = 5;
float circleArea;
float pi = 3.14;
circleArea = pi * (radius* radius);
cout << "The area is: " << setprecision(13)<< circleArea << endl;
system("pause");
return 0;
}
Setprecision only shows significant digits unless you explicitly tell it you want to show as fixed point. So if you want it to show trailing zeros, you need to make output fixed:
cout << "The area is: " << setprecision(13) << fixed << circleArea << endl;
Well, what I'm trying to do is to get the are of a circle where the radius is 5 and I want to show a more precise number, in this case I think it should be 78.5374984741