Given a variable of float type, how to output it with 3 digits after the decimal point, using iostream in C++?
If you want to print numbers with precision of 3 digits after decimal, just add the following thing before printing the number cout << std::setprecision(3) << desired_number. Don't forget to add #include in your code.
cout << std::setprecision(3) << desired_number
#include