int myArr[5]; for(int x=0; x<5; x++) { myArr[x] = 42; } | SoloLearn: Learn to code for FREE!

0

int myArr[5]; for(int x=0; x<5; x++) { myArr[x] = 42; }

I can't understand can somebody explain me plss

12/10/2017 5:33:02 PM

utkarsh

2 Answers

New Answer

+3

x variable is going to be used within for loop, as an index of the array myArr[]. That array's size has been defined at the time of declaration. 5. So we are going to loop for x until it reaches 4 (x<5). because array's index are 0 based. so last element (5th) will be at the index 4. In every loop, myArr[x] is 42. Since x will be from 0 to 4, myArr's every element will be 42.

0

thanks