0
For loop with array loop i cannot understand it
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.
+ 2
Can you give an example?
+ 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.
0
is x element of int myarr[5] I cannot understand what is myarr[x] mean
0
thank you for explained that