Please make me a script or explanation on how this source code functions and what are the codes it has #include using namespace std; struct seniorcitizen { int number; char firstname[50]; char middlename[50]; char lastname[50]; string address; int age; string healthstatus; } s[3]; int main() { cout << "Enter information of senior citizens: " << endl; // storing information for(int i = 0; i < 3; ++i) { s[i].number = i+1; cout << " Sno: " << s[i].number<< endl; cout << "Enter first name: "; cin >> s[i].firstname; cout << "Enter Middle Name: "; cin >> s[i].middlename; cout << "Enter Last name: "; cin >> s[i].lastname; cout << "Enter address: "; cin >> s[i].address; cout<< "Enter age :"; cin>> s[i].age; cout <<" Enter health status: "; cin>> s[i].healthstatus; cout << endl; } cout << "Displaying Information: " << endl; // Displaying information for(int i = 0; i < 3; ++i) { cout << "\nSno: " << i+1 << endl; cout << " First Name: " << s[i].firstname << endl; cout << "Middle Name: " << s[i].middlename << endl; cout << "last Name: " << s[i].lastname << endl; cout << "Address: " << s[i].address << endl; cout << " Age: " <
Please make me a script or explanation on how this source code functions and what are the codes it has
#include<iostream>
using namespace std;
struct seniorcitizen
{
int number;
char firstname[50];
char middlename[50];
char lastname[50];
string address;
int age;
string healthstatus;
} s[3];
int main()
{
cout << "Enter information of senior citizens: " << endl;
// storing information
for(int i = 0; i < 3; ++i)
{
s[i].number = i+1;
cout << " Sno: " <<
s[i].number<< endl;
cout << "Enter first name: ";
cin >> s[i].firstname;
cout << "Enter Middle Name: ";
cin >> s[i].middlename;
cout << "Enter Last name: ";
cin >> s[i].lastname;
cout << "Enter address: ";
cin >> s[i].address;
cout<< "Enter age :";
cin>> s[i].age;
cout <<" Enter health status: ";
cin>> s[i].healthstatus;
cout << endl;
}
cout << "Displaying Information: " << endl;
// Displaying information
for(int i = 0; i < 3; ++i)
{
cout << "\nSno: " << i+1 << endl;
cout << " First Name: " << s[i].firstname << endl;
cout << "Middle Name: " << s[i].middlename << endl;
cout << "last Name: " << s[i].lastname << endl;
cout << "Address: " << s[i].address << endl;
cout << " Age: " <<s[i].age <<endl;
cout << " Health status: " <<s[i].healthstatus <<endl;
}
return 0;
}
Step by step
Solved in 3 steps with 2 images