Printing the correct number of decimal places with cout
With <iomanip>, you can use std::fixed and std::setprecision Here is an example #include <iostream> #include <iomanip> int main() { double d = 122.345; std::cout << std::fixed; std::cout << std::setprecision(2); std::cout << d; } And you will get output 122.34