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]
3 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]3 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
Given a normally distributed data set of 500 observations measuring tree heights in a forest,
bearhunter [10]

Answer:

Since we have the normally distributed data set of the 500 observations. hence, according to the formula there will be 95% of the total observation within two standard deviations from the mean.

Hence, no. of observations will be= 95% of 500= 95 *5 = 475

Also remember standard deviation is (Xi-X')²

The standard deviation is the measurement of the dispersion of the data set from the mean. And its quite important in Data science.

Explanation:

The answer is self explanatory.

3 0
3 years ago
Create a public class Dog that stores a single double age set by the constructor. (Reject negative ages using assert.) Dog shoul
hjlf

Answer:

Explanation:

The following is written in Java and has the methods as requested in the question...

class Dog {

   private double age;

   public Dog(double v) {

       assert v >= 0:" Not valid";

       this.age = v;

   }

   public boolean isOlder(Dog dog1, Dog dog2) {

       if (dog1.age > dog2.age) {

           return true;

       } else {

           return false;

       }

   }

}

7 0
3 years ago
Let T be the statement: The sum of any two rational numbers is rational. Then T is true, but the following "proof is incorrect.
ikadub [295]

Answer:

the mistake is in the first statement.

Explanation:

Now lets us put the statement into consideration:

"The sum of any two rational numbers is irrational"

The negation is: " there exists a pair of rational numbers whose sum is irrational". (Existence of at least one of such a pair).

The negation is not "the sum of any two rational numbers is irrational"

Therefore the mistake is in the first statement and it is due to incorrect negation of the proof.

4 0
3 years ago
Hey guys,i have a question. 2x + 7x + 1y.how do i simplify it
Nastasia [14]

Answer:

9x+y Lol use photo math :) !!

5 0
3 years ago
A typical, small, dry cell battery has a voltage of A. 6.0 volts. B. 1.0 volts. C. 12.0 volts. D. 1.5 volts.
Bad White [126]
The answer is D 1.5 volts
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which person would be the best fit for a career in the information technology field?
    14·1 answer
  • In this assignment you will write a function that will calculate parallel resistance for up to 10 parallel resistors. Call the f
    12·1 answer
  • The hot wires in a service entrance panel are most likely to be covered with ________ insulation. A. red B. green C. gray D. whi
    14·1 answer
  • In a virtual memory system, each process must have its own page table.(True or False?)
    13·1 answer
  • When someone registers a domain name that is a company's trademark, hoping to resell it to the company at an exorbitant profit,
    14·2 answers
  • The security option in MySQL, that when enabled, limits where a file can be loaded from when using the LOAD DATA INFILE command
    6·1 answer
  • Welcome back to school people!
    15·2 answers
  • Which of the following is a setting in both the Transparency panel and the Mirror panel?
    10·1 answer
  • "If possible, always bring print-outs of your slides for your audience
    7·2 answers
  • enter formula that uses the IF function to test whether the number of years of experience (cell M5) is greater than or equal to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!