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

Why array index start from zero?

Any one knows the answer then please tell me

11th Mar 2021, 5:21 PM
Gayatri Borse
Gayatri Borse - avatar
4 Answers
11th Mar 2021, 5:45 PM
Jayakrishna 🇮🇳
+ 2
Because we programmers count from zero
12th Mar 2021, 8:49 PM
Kevin Brian
Kevin Brian - avatar
11th Mar 2021, 5:27 PM
Soumik
Soumik - avatar
0
Computers generally count from 0. Back in the old days code was very low level, sometimes you didn't even have arrays, you had to manually calculate offsets in memory, and an offset of 0 would be the first element. It's a standard from the past which we didn't wanna break, so we kept it. Some languages decided that this tradition is not important, and they count from 1. It's all language specific.
12th Mar 2021, 12:57 AM
inxanedev!
inxanedev! - avatar