Why array start with 0th location
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
brunda kRank #3,804 · 389 reputationPosted Feb 18, 2013, 2:40 AM EST
VulpesRank #55 · 29.2K reputationPosted Feb 18, 2013, 3:56 AM EST
In C array elements are laid out one after the other in memory and are typically accessed using pointers.
If the first element always has a subscript of zero, then this means that there is no need to deduct the subscript of the first element when working out the offset into the array at which a particular element is stored or to store the starting subscript itself. This clearly improves the efficiency of the underlying implementation.
In C#, arrays are stored and accessed in a similar fashion though the underlying use of pointers is hidden from the programmer except in the case of 'unsafe' code.