setprecision c++ code example
Example 1: ‘setprecision’ was not declared in this scope
//You have to include header file
Example 2: set precision with fixed c++
int x = 109887;
cout << fixed << setprecision(3) << x;
Example 3: setprecision c++
// setprecision example
int main () {
double f =3.14159;
std::cout << std::setprecision(5) << f << '\n';
std::cout << std::setprecision(9) << f << '\n';
std::cout << std::fixed;
std::cout << std::setprecision(5) << f << '\n';
std::cout << std::setprecision(9) << f << '\n';
return 0;
}