0

How can i print output with a specific number of digits after decimal in cpp

15th Dec 2020, 4:20 PM
Pulluri Sai Lalith
Pulluri Sai Lalith - avatar
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
15th Dec 2020, 4:31 PM
Ipang