136k views
4 votes
Write the C++ code (NOT a full program) that prompts the user to enter 50 numbers and fills the array guestCount with these 50 numbers, so that the first number input is in the first element of the array, the second input in the second element, etc.

User Justmscs
by
3.6k points

1 Answer

5 votes

Answer:

The code is as follows:

int guestCount[50];

for(int i = 0; i<50;i++){

cout<<"guestCount "<<i+1<<": ";

cin>>guestCount[i];

}

Step-by-step explanation:

This declares the array

int guestCount[50];

This iterates through the array (50 elements)

for(int i = 0; i<50;i++){

This prompts the user for each array element

cout<<"guestCount "<<i+1<<": ";

This gets the input from the user

cin>>guestCount[i];

}

User Soma Yarlagadda
by
3.8k points