Answer:
Following are the code to this question:
for (i = 0; i <3; ++i)//defining loop to print value
{
cout<<runTimes[i]<<endl;//print value
}
Explanation:
Full program code to this question:
#include<iostream>//defining header file
using namespace std;
int main() //defining main method
{
const int NUM_ELEMENTS = 5;//defining const integer variable
int runTimes[NUM_ELEMENTS]; //defining integer array
int i;//defining integer variable
for (i = 0; i < NUM_ELEMENTS; ++i)//defining loop to input value
{
cin >> runTimes[i];//input value
}
cout<<"print three elements value of array: "<<endl;
for (i = 0; i <3; ++i)//defining loop to print value
{
cout<<runTimes[i]<<endl;//print value
}
return 0;
}
Output:
Please find the attachment.
Description:
- In the above code, an integer const variable "NUM_ELEMENTS" is declared, that assign value "5" which is array size, in the next step, an array "runTimes" is declared.
- In the next step, for loop is used, that uses an integer variable "i", which is used to input all array elements.
- In the next line, another for loop is used, which uses "i" variable, which starts from 0 and ends when its value less than 3, inside the loop print method, used that prints 3 array elements.