// Example to illustrate formatting of decimal (floating point) values #include using namespace std; int main() { double x, y, z; cout << "Enter 3 double (floating-point) values: \n> "; cin >> x >> y >> z; cout.setf(ios::scientific); cout.precision(2); cout << "The first number, to 2 decimal places: " << x << '\n'; cout.precision(3); cout << "The second number, to 3 decimal places: " << y << '\n'; cout.precision(6); cout << "The third number, to 6 decimal places: " << z << '\n'; cout << '\n'; cout.precision(0); cout << "The first number, to 0 decimal places: " << x << '\n'; cout.precision(9); cout << "The second number, to 9 decimal places: " << y << '\n'; cout.precision(4); cout << "The third number, to 4 decimal places: " << z << '\n'; cout << "\nSee ya!\n"; }