Create two arrays with 5 elements each: one will hold Strings and the second will hold integers. Write a program to ask the user to enter 5 student names and their ages. Output the data from the parallel arrays.

Respuesta :

Answer:

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main() {

   string name[5];  

   int age[5];  

   int i,j;  

   for ( i = 0; i<=4; i++ ) {  

       cout << "Please enter student's name:";  

       cin >> name[i];  

       cout << "Please enter student's age:";  

       cin >> age[i];          

   }  

for (i=0;i<=4;i++){

   cout<<"Age of  "<< name[i]<<"  is  "<<age[i]<<endl;  

}

}

Output of above program is displayed in figure attached.

Ver imagen afsahsaleem