Answer:
#include<iostream>
using namespace std;
int main()
{
string f[50],l[50],str1,str; //f[] will store firstnames and l[] lastnames
int i;
cout<<"Enter firstnames and enter # to stop\\";
cin>>str;
for(i=0;str!="#";i++) //# will be the sentinel character
{
f[i]=str;
cin>>str;
}
cout<<"Enter lastnames and enter # to stop\\";
cin>>str1;
for(i=0;str1!="#";i++)
{
l[i]=str1;
cin>>str1;
}
int n=i; //n wiill be number of elements in array
cout<<"\\List of emails are : \\";
for(i=0;i<n;i++) //loop to print list of emails
{
cout<<f[i]<<"."<<l[i]<<"@mycollege.edu"<<endl;
}
return 0;
}
OUTPUT :
Please find the attachment below.
Step-by-step explanation:
Two arrays are maintains which are f[] and l[]. f[] stores firstnames and l[] stores lastnames. First 2 loops are reading firstnames and lastnames which will break if '#' is typed as it is considered as a sentinel character here which is assured by checking the condition in the loop. Then n variable is used to store the length of the arrays. Both arrays have to be of equal length as email ids contains both firstname and lastname. Then a loop is created to print email ids of the format specified by using arrays f[] and l[].