set precision in c++ to 6 digit code example
Example 1: set precision in c++
#include <iostream>
#include <iomanip>
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;
}
Example 2: how to print 5 precision float in c++
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double Number=10.3454;
printf("%.3lf",Number);
return 0;
}