Why the array index start from 0 ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why the array index start from 0 ?

array

14th Oct 2017, 4:15 AM
Suraj Prashar
Suraj Prashar - avatar
5 Answers
14th Oct 2017, 4:24 AM
John Wells
John Wells - avatar
+ 2
Because it indicated the number of elements to its left.As for negative indices, they indicate how much the positive index differs from the length of the array
14th Oct 2017, 4:28 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 2
In some other languages it starts at 1, but essentially the usual reason is because 0 makes more sense than 1 in computing when you bring binary into question. 0 is the smallest number that can represented in binary, therefore you save a bit by starting from 0. For example, starting from 0 in binary: 0, 1, 10, 11, 100, 101, etc starting from 1 in binary: 1, 10, 11, 100, 101, etc
14th Oct 2017, 4:51 AM
aklex
aklex - avatar
+ 1
it's based on what happens when reserve memory on RAM
14th Oct 2017, 6:25 AM
Hamid Reza Gholami Boroujeni
Hamid Reza Gholami Boroujeni - avatar
+ 1
Because. Binary numbers Computers communicate using binary numbers such as 1010001001
14th Oct 2017, 7:08 AM
I_aM_cArly
I_aM_cArly - avatar