I need this code in C++. A family has 4 members. You need to write a program to
ID: 643334 • Letter: I
Question
I need this code in C++.
A family has 4 members. You need to write a program to store the information of the family members and then to display it. The information to be stored for each member are:
First Name
Last Name
Date of Birth
Telephone number
Age
The age needs to be calculated based on current date and the Date of Birth. All these information except the age should be obtained from the user and should be stored in an array. Once the array has been populated (for all 4 members), print the complete information about each member of the family. Help: You may like to create an array of struct.
Explanation / Answer
#include <iostream>
using namespace std;
const int MAX_PEOPLE = 4;
struct inflatable {
string firstName;
string lastName;
int birthMonth;
int birthDay;
int birthYear;
string telephone;
int age;
};
int main() {
inflatable members [MAX_PEOPLE];
for (int i=0; i<MAX_PEOPLE; i++) {
cout << "Enter first name: ";
cin >> members [i].firstName;
}
cout << members [1].firstName;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.