Original Post
Hi!
I''m testing the setprecision and would like to have 3 decimals instead of 3
If I input 3 and 4 in the program the output is 21.2
I want the output to have 3 significant figures (output: 21.206)
I''m using Visual C++ 6.0 with unmodified standard libaries
The code:
#include <iostream.h>
#include <iomanip.h>
#include <math.h>
#define PI 3.1415929
double d, l, v;
void main()
{
cout << "d (dm) : ";
cin >> d;
cout << "l (dm) : ";
cin >> l;
double h, r;
r = d/2;
h = l - d;
v = 4*PI*r*r*r/3 + PI*r*r*rh;
cout << ios:fixed << setprecision(3); // something is wrong
cout << "v: = " << v << "\n";
cin.get();
cin.get();
}