asked 57.3k views
2 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:

asked
User DaveC
by
8.2k points

1 Answer

4 votes

Answer:

Following are the code to this question:

#include <stdio.h>//defining header file

int main()//defining main method

{

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

for(int k=0;k<3;k++)//defining for loop for print value

{

printf("%d\\",runTimes[k]);//print value with a new line

}

return 0;

}

Output:

800

775

790

Step-by-step explanation:

In the above-given C language code, an array "runTimes" is defined, which holds the number of integer values.

In the next step, a for loop is defined, which uses the "k" variable, which starts from 0 and ends when its value is less than 3.

In the for loop, it uses the print method with "\\", that prints the array value in the new line.