I don\'t get it why i in fillArray method ends up being equal to 10 even though the array score is filled only up to index 9>
You must understand exactly how the for loop works to understand what is going on, and why i is 10 after the for loop in fillArray.
false, break out of the loop.In the last iteration of the i for loop, i is 9, and index 9 is assigned in the array, step 3. Step 4 performs the increment, and i is now 10. Then the condition is tested, which is false, and the loop is exited. i is now 10.
However, in your main for loop, you print the value in the body instead of examining the looping variable afterwards. The last iteration is when i is 10, because the condition is different: i < 11. If you were to print i after that for loop, you'll see it's 11.