1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vesna_86 [32]
2 years ago
12

Write three statements to print the first three elements of array runTimes. Follow each statement with a newline. Ex: If runTime

= {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]). See "How to Use zyBooks".
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
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;
}
Please help me with this problem using c++.

Computers and Technology
1 answer:
yawa3891 [41]2 years ago
8 0

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.  

You might be interested in
The ________ of the operating system enables users to communicate with the computer system. Select one: A. user interface B. mod
Mumz [18]
The user interface of the operating system
8 0
3 years ago
So this is what i use to code and all of that
givi [52]

Answer: yeah!

Explanation:

Have a good day!

5 0
2 years ago
Jordan likes to use his smartphone in his car. He uses it as a navigation device and connects it via Bluetooth to listen to musi
Levart [38]

Answer:

I think A Bluetooth receiver is causing the smartphone to over heat

8 0
2 years ago
Q.N.2. Write T for true statement and 'F' for the false one: with a) Monitor is called visual display unit. b) IPO is the basic
Svetradugi [14.3K]

Answer:

a. t

B.f

c.f

d.f

e.f

f.f

g. f

4 0
3 years ago
What is the difference between the Paste Special and Paste Link options?
kotegsom [21]
Paste Link lets you automatically update the referenced document.
8 0
3 years ago
Read 2 more answers
Other questions:
  • Meaning of page break​
    8·1 answer
  • USDA-APHIS Animal Care Resource Policy #12 "Considerations of Alternatives to Painful/Distressful Procedures" states that when a
    11·1 answer
  • Which of the following attack is a threat to confidentiality?
    10·1 answer
  • Software applications called _____ provide the means to record information that passes through a computer or router that is hand
    10·1 answer
  • URGENT!!! Which file format is used mainly in the Microsoft Windows operating system?
    15·2 answers
  • I am a bacterium. I cause stomach cramps and diarrhea. I am caused by eating rotten foods
    7·2 answers
  • Which of the following is a key aspect of any IT position? installation of fiber optic cables
    14·2 answers
  • Complete the function favoriteFlower(). Note that the program will not run as is because the function is incomplete. The purpose
    15·1 answer
  • You would like to see only the last 15 lines of /home/user/log file on your linux machine. Which command line interface (cli) co
    9·1 answer
  • TRUE/FALSE. a good with many close substitutes is likely to have relativelyelastic correct demand, since consumers can easily ch
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!