How would I modify code, like the code shown below, to exclude the constant VALUE_1 when using setprecision(2) so that it will display 3 decimals instead of 2 like the others?
#include <iostream>
#include <iomanip>
using namespace std;
const double VALUE_1 = .011;
int main(void)
{
double value2;
double value3;
value2 = 2.362;
value3 = 5;
cout << fixed << setprecision(2);
cout << value2 << endl;
cout << VALUE_1 << endl;
cout << value3 << endl;
return 0;
}
I tried the following fix and it works fine, but is there anything else that doesn't look so improvised? Or is this the intended method?
cout << value_2 << endl;
cout << setprecision (3) << value_1 << endl;
cout << setprecision (2) << value_3 << endl;