// Dev-C++ Program file: formatop.cpp // This program demonstrates print formats #include #include // function prototypes void printHeader(); void getInfo(); void displayInfo(); // global declarations using namespace std; short int Age; float Salary; char Name[11]; char Gender, Eop; bool Done = false; int main() { printHeader(); while (! Done) { getInfo(); displayInfo(); cout << "Done entering data (Y/N): "; cin >> Eop; if (Eop == 'Y' || Eop == 'y') Done = true; } cout << "End of program..." << endl; return 0; } void printHeader() { cout << "EXAMPLE OF FORMATTED OUTPUT"; cout << endl << endl; } void getInfo() { cout << "Enter a name: "; cin >> Name; cout << "Enter an age: "; cin >> Age; cout << "Enter a salary: "; cin >> Salary; cout << "Enter a gender: "; cin >> Gender; } void displayInfo() { cout << setiosflags(ios::left) << setw(20) << Name << setiosflags(ios::right) << setw(3) << Age << setprecision(2) << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setw(10) << Salary << setw(5) << Gender << endl; cout.unsetf(ios::right); }