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

// Program takes 5 numbers from a user (from console), stores them into an // ar

ID: 3929150 • Letter: #

Question


// Program takes 5 numbers from a user (from console), stores them into an
// array, and then prints them to the screen (on the same line).

// Add code to complete this program. You only need to add code where indicated
// by "ADD HERE".

#include <iostream>
using namespace std;

int main()
{
const int SIZE = 5; // size of array

// ADD HERE - create an array of integers that will hold 5 integers.

cout << "please enter 5 integers : " << endl;

// For loop takes 5 integers from user and stores them in the array
for (int i = 0 ; i < SIZE ; i++)
{
// ADD HERE - take user's input and store it in the array you created

   
}

// ADD HERE - Write a for loop to print the array to the screen

return 0;
}
for c++ programming

Explanation / Answer

Answer:

C++ Program:

#include <iostream>
using namespace std;
int main()
{
const int SIZE = 5; // size of array
int array[5]; // ADD HERE - create an array of integers that will hold 5 integers.
cout << "please enter 5 integers : " << endl;
// For loop takes 5 integers from user and stores them in the array
for (int i = 0 ; i < SIZE ; i++)
{
// ADD HERE - take user's input and store it in the array you created

cin >> array[i];
}
// ADD HERE - Write a for loop to print the array to the screen
for (int i = 0 ; i < SIZE ; i++)
{

cout << array[i];
}
return 0;
}