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;
}
#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;
}
Comments
Leave a comment