set precision fixed in c++ code example
Example 1: setprecision in c++
#include<iomanip>
#include <iostream>
using namespace std;
int main()
{
int num = 45;
cout << "it is: " << fixed << setprecision(2) << num << " the end"<< endl;
return 0;
}
Example 2: set precision with fixed c++
int x = 109887;
cout << fixed << setprecision(3) << x;
Example 3: precision of fixed in c++
#include <iomanip>
// the rest of the code
double a = 4.032;
cout << fixed << setprecision(2);
cout << a;
// done;