64 686
Assignments Done
99,3%
Successfully Done
In September 2018

Answer to Question #50914 in C++ for Zexy

Question #50914
Write a program that allows a user to use the keyboard to input the first and last names
of 40 friends, up to 50 characters each. Display the names 15 at a time, pausing to let the
user press a key before the list continues. Save the file as Friends40.cpp.
Expert's answer
Program:
Friends40.cpp
#include <iostream>
#include <string>
#include <stdlib.h>
#define MAX_LEN 50
#define MAX_STUD 20
using namespace std;
/*Write a program that allows a user to use the keyboard to input the first and last names
of 40 friends, up to 50 characters each. Display the names 15 at a time, pausing to let the
user press a key before the list continues. Save the file as Friends40.cpp*/
struct friends
{
char FirstName[MAX_LEN];
char LastName[MAX_LEN];
};
int main()
{
friends MyFriends[MAX_STUD];
int i;
for(i=0;i<MAX_STUD;i++)
{
 cout<<"Input first name for "<<(i+1)<<": ";
 cin>>MyFriends[i].FirstName;
 cout<<"Input last name for "<<(i+1)<<": ";
 cin>>MyFriends[i].LastName;
}
cout<<"List of friends"<<endl;
for(i=0;i<MAX_STUD;i++)
{
 if((i==0)&&(i>0)) //every 15 lines (if not first line)
system&#40;"pause"&#41;;
 cout<<(i+1)<<". "<<MyFriends[i].FirstName<<" "<<MyFriends[i].LastName<<endl;
}
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions