Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTimes = {800, 775, 790, 805, 808}, print: 800 775 790
Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTimes = {800, 775, 790, 805, 808}, print:
800 775 790
Note: These activities will test the code with different test values. This activity will perform two tests, both with a 5-element array (int runTimes[5]).
Also note: If the submitted code tries to access an invalid array element, such as runTime[9] for a 5-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message.
#include <iostream>
using namespace std;
int main() {
const int NUM_ELEMENTS = 5;
int runTimes[NUM_ELEMENTS];
int i;
for (i = 0; i < NUM_ELEMENTS; ++i) {
cin >> runTimes[i];
}
/* Your solution goes here */
return 0;

Indexing of array starts with 0.
Here we need a loop which will run for index values 0 to 2 since we need to print 3 numbers.
Step by step
Solved in 5 steps with 2 images









