+ 2

Why array index size starts with zero

10th May 2017, 2:27 PM
keshu
keshu - avatar
6 Respostas
+ 8
why not
10th May 2017, 2:33 PM
NimWing Yuan
NimWing Yuan - avatar
+ 6
Because it's really an offset telling the computer how many items away from the first item a thing is.
10th May 2017, 3:08 PM
David Ashton
David Ashton - avatar
+ 4
Good info here: http://stackoverflow.com/questions/7320686/why-does-the-indexing-start-with-zero-in-c It looks like there's a good memory/mathematical reason to starting at 0, and a definition reason. The definition reason would be because the index is how far away the element is from the head pointer of the array (the first element). So the first element is 0 index's away. Why they use that definition, I'm not sure. I suggest you check out the link above.
10th May 2017, 3:18 PM
Rrestoring faith
Rrestoring faith - avatar
+ 3
Cpu have address start from 0000, that's why array should start from index 0, if not it would waste a memory space.
10th May 2017, 3:39 PM
Calviղ
Calviղ - avatar
0
I to dont know today interviewer asked me???
10th May 2017, 2:35 PM
keshu
keshu - avatar
0
Becz the numbers from 0 so machine is designed like that
10th May 2017, 3:26 PM
keshu
keshu - avatar