Prices usually show two digits after the decimal point, even when the last digit is zero. Calculation and presentation are different jobs: keep an exact small amount in integer cents, then choose a display format.
<iomanip> provides formatting tools called stream manipulators. They are sent to std::cout with <<, like values, but configure later output rather than printing a label.
#include <iostream>
#include <iomanip>
int main() {
int cents = 725;
double dollars = static_cast<double>(cents) / 100;
std::cout << std::fixed << std::setprecision(2);
std::cout << "Price: $" << dollars << "\n";
return 0;
}
std::fixed requests ordinary fixed decimal notation. With that setting, std::setprecision(2) requests two digits after the decimal point. The example prints Price: $7.25. A value of 7.5 would display as 7.50, and a whole value of 7 would display as 7.00.
Use both manipulators together for this purpose. Without std::fixed, precision has a different meaning: it controls significant digits rather than a fixed count of decimal places. These settings persist for subsequent floating-point output on the stream.
The starter already converts 450 cents to dollars. Run it unchanged to see the unformatted price, then add the formatting statement before that output. The number being displayed stays the same; your edit makes the trailing zero visible. Keep the calculation and output statement rather than replacing them with a fixed price string. Formatting controls presentation, not the exactness of floating-point storage.
std::cout with std::fixed and std::setprecision(2) at the comment so the price prints as Price: $4.50.Edit main.cpp, press Run to inspect the Console, then Submit to check these results.