0

Hi all,

Out of curiosity, why does an array start with 0 instead of 1? It would cut down of alot of confusion if it did.

Thanks

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by KimJack
0

You not gone be first asking such a question. If you google in most programmming forums such a question been asked. I do not know the answer but I presume it is from past times of old languages like assembler, pascal etc where programer besides of creating program had to keep an eye on memory management. All computer data are digitally organized(ie in binary) even today 0- 0000, 1-0001, 2 0010, 3-0011...
It is said the C programming language actualy made zero array position widely used. Duno....
If you interested may want to read this document by Edsger W. Dijkstra called Why numbering should start at zero

0

Just a stab in the dark, but I, too, think it's memory management. An array is represented in memory by a pointer to its first element. The index of the array can indicate the offset from the value of that pointer.

0

Thanks cscgal. That makes alot of sense. Still would be nice if it started at 1 and used 0 as an offset instead.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.