+ 2

Can any one answer why array index always starts with 0??

31st May 2017, 10:02 AM
Sandesh sharma
Sandesh sharma - avatar
4 Respuestas
+ 11
In reference to SO, The expression of an array with index of n refers to a memory location n-elements away from the starting element. The first element of the array is exactly contained in the memory location that array refers (0 elements away), so it should be denoted as array[0]. for more info: http://developeronline.blogspot.com/2008/04/why-array-index-should-start-from-0.html
31st May 2017, 10:05 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
It is a convention created by the creator of languages. It can be explained in Hatsy's reply, but this is a common understanding
31st May 2017, 10:15 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 1
Pretty convinced with hatsy's reply.. Thanks a lot guys
31st May 2017, 10:17 AM
Sandesh sharma
Sandesh sharma - avatar
+ 1
Because WKT arrays are ends with null character. If we declare a array kd[5] in the sense, It value starts from kd[0] to kd[4] for five elements and the kd[5] is stored with a NULL character.
2nd Jun 2017, 5:15 AM
Dinesh Kesawamoorthy
Dinesh Kesawamoorthy - avatar