// Example to illustrate formatting of decimal (floating point) values // // Does all the same features as formats1.cpp, but with manipulators #include #include using namespace std; void PrintData(int x, double y); int main() { int a; double b; cout << "Enter an integer: "; cin >> a; cout << "Enter a double: "; cin >> b; cout << "\n"; PrintData(a,b); cout << "\nUsing manipulators: fixed, showpoint, left, setprecision(5)\n"; cout << fixed << showpoint << left << setprecision(5); PrintData(a,b); cout << "\nUsing manipulators: scientific, right, setprecision(1)\n"; cout << scientific << right << setprecision(1); PrintData(a,b); cout << "\nUsing manipulators: showpos, setfill('.')\n"; cout << showpos << setfill('.'); PrintData(a,b); cout << "\nUsing manipulator: internal\n"; cout << internal; PrintData(a,b); cout << "\nSee ya!\n"; } void PrintData(int x, double y) // uses setw() manipulator to specify field widths { cout << setw(15) << x; cout << setw(25) << y; cout << setw(30) << "Hello, World"; cout << '\n'; }