Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Complete the following assignment in C++ Ask the user for five names. Output tho

ID: 3818345 • Letter: C

Question

Complete the following assignment in C++

Ask the user for five names. Output those names. Put an integer before each name to indicate the ordering

This program is tricky because array subscripts start at zero, but the output of this program goes from one to five. Keep this in mind when coding.

Required output:

___________________________________________________________________________________________________________________________________________________

Modify the previous program. Show the user a list of the names (with integers before each name). Allow the user to select which friend is his/her best friend.

Required output:

Explanation / Answer

#include <iostream>

using namespace std;

int main()
{
string friends_list[5]; //Declaring a friends list array of strings using string data type
cout << "enter five names" << endl;

for(int i=0;i<5;i++)
{
cout<<"enter friend "<<(i+1)<<endl;
cin>>friends_list[i]; //storing friends names to friends_list array
}
cout<<"Here are all of those names "<<endl;
for(int i=0;i<5;i++)
{
cout<<"friend "<<(i+1)<<" is "<<friends_list[i]<<endl; //printing friends names

}

int y; //declaring an integer for best friend choice
cout<<"Which friend is your best friend? "<<endl;
cin>>y;
cout<<friends_list[y-1]<<"? Yes,"<<friends_list[y-1]<<" is awesome"<<endl; //printing the best friend
  
return 0;
}

Sample output:

enter five names enter friend 1 Ram enter friend 2 Raghu enter friend 3 Raja enter friend 4 Ravi enter friend 5 Subbu Here are all of those names friend 1 is Ram friend 2 is Raghu friend 3 is Raja friend 4 is Ravi friend 5 is Subbu Which friend is your best friend? 5 Subbu? Yes,Subbu is awesome

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote