Create a program that allows the user to input a list of first names into one array and last names into a parallel array. Input should be terminated when the user enters a sentinel character. The output should be a list of email addresses where the address is of the following form: [email protected].
please help!!!!
Here is the program code for the above question. Hope it Helps!
PROGRAM CODE:
#include<iostream>
using namespace std;
int main()
{
string first[100],last[100],str,str1; //first[] array will store firstnames and last[] array lastnames
int i;
cout<<"Enter firstnames and enter $ to stop:\n";
cin>>str; // getting input
for(i=0;str!="$";i++) //$ will be the sentinel character
{ // loop condition to receive input until sentinel character is received as input
first[i]=str;
cin>>str;
}
cout<<"Enter lastnames and enter $ to stop:\n";
cin>>str1; // getting input
for(i=0;str1!="$";i++)
{
last[i]=str1;
cin>>str1;
}
int n=i; //'n'represents number of elements in array
cout<<"\nList of emails are : \n";
for(i=0;i<n;i++) //loop to print list of emails
{
cout<<first[i]<<"."<<last[i]<<"@mycollege.edu"<<endl;
}
return 0;
}
Screenshot of program code:
OUTPUT:
Get Answers For Free
Most questions answered within 1 hours.