Answer to Question #260508 in C++ for malika

Question #260508

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


#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];

  }


  int main(){

 int runTime [5]= {800, 775, 790, 805, 808};

 

 for(int i=0; i<3; i++){

 

 cout<<runTime[i]<<endl;

 

}

}/* Your solution goes here */


  return 0;

}


1
Expert's answer
2021-11-03T17:48:17-0400
#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];
    
    }


    int runTime [5]= {800, 775, 790, 805, 808};


    for(int i=0; i<3; i++){
        cout<<runTime[i]<<endl;
    }


    return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS