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

Why we start the index of array from 0?

6th Dec 2015, 6:38 PM
PRIYANKA YAWALKAR
PRIYANKA YAWALKAR - avatar
2 Answers
0
Edsger Dijkstra actually wrote a note in 1982 advocating for zero-based indexing. The difference between the upper & lower bound should be the length of the sequence. We have two choices for upper and lower bounds: 1 <= i < N+1 or 0 <= i < N. Clearly, putting N+1 in the range is ugly, so we should prefer indexing starting from 0.
25th Dec 2015, 3:12 AM
Saumya Sharma
0
0 is off set shown from the base address to first element........
23rd Jul 2016, 12:50 PM
Kamal Singh
Kamal Singh - avatar