write the subprogram to share individual elements of the array
+++++++++++ code ++++++++++++++++++++
const int size = 3;
struct student
{
string name;
string address;
string city;
string state;
int zip;
char gender;
int idno;
float gpa;
};
void getInfo(int i, student* s)
{
cout << "student " << i+1 << "'s Name? ";
getline(cin, s[i].name);
cout << "student " << i+1 << "'s address? ";
getline(cin, s[i].address);
cout << "student " << i+1 << "'s city? ";
getline(cin, s[i].city);
cout << "student " << i+1 << "'s state? ";
getline(cin, s[i].state);
cout << "student " << i+1 << "'s zip code? ";
cin >> s[i].zip;
cin.ignore(1000, 10);
cout << "student " << i+1 << "'s gender? [M/F]";
cin >> s[i].gender;
cin.ignore(1000, 10);
cout << "student " << i+1 << "'s ID number? ";
cin >> s[i].idno;
cin.ignore(1000, 10);
cout << "student " << i+1 << "'s gpa? ";
cin >> s[i].gpa;
cin.ignore(1000, 10);
cout << endl;
}
void printInfo(int i, student* s)
{
cout << "student (" << i+1 << ")" << endl;
cout << "Name: " << s[i].name << endl;
cout << "Address: " << s[i].address << endl;
cout << "City: " << s[i].city << endl;
cout << "State: " << s[i].state << endl;
cout << "Zip code: " << s[i].zip << endl;
cout << "Gender: " << s[i].gender << endl;
cout << "ID number: " << s[i].idno << endl;
cout << "GPA: " << s[i].gpa << endl;
cout << endl;
}
int main()
{
student s[size];
for (int i = 0; i < size; i++)
{
getInfo(i, s);
}
for (int i = 0; i < size; i++)
{
printInfo(i, s);
}
return 0;
}