125k views
5 votes
Write three statements to print the first three elements of vector runTimes. Follow each with a newline. Ex: If runTimes = {800, 775, 790, 805, 808}, print: 800 775 790

User Ononononon
by
5.6k points

1 Answer

5 votes

Answer:

Following are the code to the given question:

#include <iostream>//header file

using namespace std;

int main()//main method

{

int runTimes[] = {800, 775, 790, 805, 808};//defining array of integer

for(int x=0;x<3;x++)//defining for loop to print three element of array value

{

printf("%d\\",runTimes[x]);//print array value

}

return 0;

}

Output:

Please find the attached file.

Step-by-step explanation:

In this code, an array integer "runTimes" is declared that holds the given array values, and in the next step, a for loop is declared.

Inside the loop, an integer variable x is declared that starts from 0 and ends when its value less than 3 in which we print the first three array element values.

Write three statements to print the first three elements of vector runTimes. Follow-example-1
User Shrujan Shetty
by
6.4k points