+ 1

Why do list/array index starts from zero(0)?

It's been a while now..! That I have been into programming , but I wasn't satisfied why list/array index starts from zero(0)?? While Lua starts from 1 ?

11th Apr 2021, 11:15 AM
Ankith M Kashyap
Ankith M Kashyap - avatar
6 odpowiedzi
+ 9
That's the way is it
11th Apr 2021, 11:17 AM
Apongpoh Gilbert
Apongpoh Gilbert - avatar
+ 2
https://www.bing.com/search?q=why+array+index+start+with+zero
11th Apr 2021, 11:31 AM
Ipang
+ 2
We always assign a variable name to an array. So, that variable name references to a memory location where array elements are stored. The reason why index start from zero is that index is used as an offset. Suppose we have an array Arr = [1,2,3,4,5] Arr[0] actually means that first element is 0 element away from the memory location where the arr points as elements in an array are stored in a contiguous manner.
11th Apr 2021, 11:40 AM
CHANDAN ROY
CHANDAN ROY - avatar
+ 1
Everything thing begins with the value "0" and continues 1,2,....44,88,900.....etc So for an origin of anything it always stays "0" at the first place and then it develops bit by bit...
12th Apr 2021, 5:44 AM
•Đคяк รтяεคм 𝅘𝅥𝅮 ᴺ•ᵀ•ᴬˢᵘʳᵃᵖᵖᵘˡᶦ
•Đคяк รтяεคм 𝅘𝅥𝅮 ᴺ•ᵀ•ᴬˢᵘʳᵃᵖᵖᵘˡᶦ - avatar
0
THIS IS MY GUESS, MAY NOT BE TRUE!!! > probably because of binary. Binary starts from 0, therefore counting array from 0 makes sense.
11th Apr 2021, 12:19 PM
KingDaniel2004
KingDaniel2004 - avatar