0
How can i print output with a specific number of digits after decimal in cpp
2 Respostas
+ 3
Include <iomanip> header, then look at `std::fixed` and `std::setprecision()`
double number {12345.6789};
std::cout << std::fixed << std::setprecision(2) << number << std::endl;
References:
https://en.cppreference.com/w/cpp/io/manip/fixed
https://en.cppreference.com/w/cpp/io/manip/setprecision