| 1 | // File: fig0645.cpp |
| 2 | // Computer Systems, Fourth Edition |
| 3 | // Figure 6.45 |
| 4 | |
| 5 | #include <iostream> |
| 6 | using namespace std; |
| 7 | |
| 8 | struct person { |
| 9 | char first; |
| 10 | char last; |
| 11 | int age; |
| 12 | char gender; |
| 13 | }; |
| 14 | person bill; |
| 15 | |
| 16 | int main () { |
| 17 | cin >> bill.first >> bill.last >> bill.age >> bill.gender; |
| 18 | cout << "Initials: " << bill.first << bill.last << endl; |
| 19 | cout << "Age: " << bill.age << endl; |
| 20 | cout << "Gender: "; |
| 21 | if (bill.gender == 'm') { |
| 22 | cout << "male\n"; |
| 23 | } |
| 24 | else { |
| 25 | cout << "female\n"; |
| 26 | } |
| 27 | return 0; |
| 28 | } |