+ 1

Question says to store 5 integers but solution says int myarray[5].(check description)

an array starts counting from 0. i.e 0,1,2,3,4,5 which makes a total of six integers. please explain.

11th Nov 2016, 4:10 PM
Ashwin Manoj
2 Réponses
+ 4
The number "5" in int myarray[5] means how many elements the array can store. You are thinking of it as an index value; but rather, it is the amount of elements the array can store. So really, the index values for that array would be 0, 1, 2, 3, 4 and that would be five elements.
11th Nov 2016, 4:47 PM
ChrisG
ChrisG - avatar
0
Exactly
15th Nov 2016, 7:20 AM
Dartisan
Dartisan - avatar