+ 3

How many elements does arr[4][4] contain?

Doesn't an array start counting at 0? That means the answer should be (4+1)*(4+1)=25, but the answer is 16. Why doesn't it start counting at 0? If you get a number from an array at [0][1], that is valid too, so in that case it does start counting at 0.

30th May 2017, 9:18 AM
Maart
Maart - avatar
5 Réponses
+ 17
4*4 arr[4] means it contains 4 elements (0,1,2,3).....
30th May 2017, 9:20 AM
Valen.H. ~
Valen.H. ~ - avatar
+ 6
number of elements is 4*4=16 , y because number of rows in arr is 4 and columns is 4 but are indexing is from 0 to 3 ,array indexing starts with 0 that is predefined we can't change
30th May 2017, 9:20 AM
Rajyalakshmi Reddy
Rajyalakshmi Reddy - avatar
+ 4
It starts counting from 0 but ends at 3.So it is 4 * 4 =16
30th May 2017, 9:23 AM
Da' BO$
Da' BO$ - avatar
+ 2
Ah, of course. Does start counting at 0, but stops at 3. Thanks!
30th May 2017, 9:22 AM
Maart
Maart - avatar