#include <iomanip> // the rest of the code double a = 4.032; cout << fixed << setprecision(2); cout << a; // done;