Why do list/array index starts from zero(0)? | Sololearn: Learn to code for FREE!

+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 ?

4/11/2021 11:15:03 AM

Ankith M Kashyap

6 Answers

New Answer

+9

That's the way is it

+5

https://www.geeksforgeeks.org/why-array-index-starts-from-zero/

+2

https://www.bing.com/search?q=why+array+index+start+with+zero

+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.

+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...

0

THIS IS MY GUESS, MAY NOT BE TRUE!!! > probably because of binary. Binary starts from 0, therefore counting array from 0 makes sense.