+ 1

Why array index always starts from 0

23rd Dec 2016, 3:18 PM
shadab shaikh
shadab shaikh - avatar
3 Respostas
+ 24
In most programming language, the name of any array is a pointer, which is nothing but a reference to a memory location, and so the expression array[n] points to a memory location which is n-elements away from the first element. This means that the index is used as an offset. The first element of the array is exactly contained in the memory location that array points to (0 elements away), so it should always be referred as array[0]. a[i] can also be read as value at [a+i] which is denoted as *(a+i) , so it always starts at zero.
23rd Dec 2016, 4:10 PM
Remmae
Remmae - avatar
0
In computer language, the bits or bytes starts from 0 only.. if u take hexadecimal it have 0 to f and so on... likewise in array, the index starts from 0.
28th Dec 2016, 5:31 AM
Senthil Kumar M
Senthil Kumar M - avatar
- 2
that is actually how computers count dude. And it makes sense because u cant have 1 or 10 or 100 if 0 doesn't exist.
24th Dec 2016, 2:15 AM
Hanz Cliebb Tura
Hanz Cliebb Tura - avatar