C++ Programming: What code would need to be entered on line 12 so that the progr
ID: 3918647 • Letter: C
Question
C++ Programming:
What code would need to be entered on line 12 so that the program functioned as required in the comment on line 10 and 11?
Your answer must be 100% correct (all or nothing - close doesn't count).
1 2 'El#include T#include 4 const int ARRAY SIZE = 100; Eint main() 6 7 8 9 10 int arrOneHundreds [ARRAY_SIZE]; // Finish the for loop so that starting with the 2nd element every other number assigned is 100 // i.e. The array should contain the elements - 0, 100, 2, 100, 4, 100, 6, 100... 12 arroneHundreds[1] = 1; arrOneHundreds[i 1]100; 14 15 16 17 18 19 20 21 // Finish the for loop so that every element that has the value 100 in the array is printed to the screen. // Do not use a conditional (i.e "if") std::coutExplanation / Answer
Answer
for(int i=0; i<ARRAY_SIZE-1; i=i+2)
Explanation
Since i and i+1 are used inside a loop, i has to be incremented by 2 each time
i+1 is used which means the for loop can be run as long as i is less than ARRAY_SIZE.
Answer
for(int i=0; i<ARRAY_SIZE-1; i=i+2)
Explanation
Since i and i+1 are used inside a loop, i has to be incremented by 2 each time
i+1 is used which means the for loop can be run as long as i is less than ARRAY_SIZE.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.