0

For loop with array loop i cannot understand it

15th Aug 2018, 6:03 PM
Omar
6 Answers
+ 3
in the loop, the variable x takes values from 0 to 4. in the first iteration, x=0 so myarr[x] is myarr[0], the first element of the array. The same goes for the other values of x.
15th Aug 2018, 7:21 PM
davy hermans
davy hermans - avatar
+ 2
Can you give an example?
15th Aug 2018, 6:06 PM
davy hermans
davy hermans - avatar
+ 2
i can see that the program makes an array with 5 elements. myarr[5] Here the number 43 is placed on every position of the array by the loop. so the array is: [43,43,43,43,43] The first position always gets index 0 (here represented by x), the last index is 4. Finally every position is printed.
15th Aug 2018, 6:45 PM
davy hermans
davy hermans - avatar
0
is x element of int myarr[5] I cannot understand what is myarr[x] mean
15th Aug 2018, 7:12 PM
Omar
0
thank you for explained that
16th Aug 2018, 9:12 AM
Omar