+ 1

Arrays and accessing itā€™s max size

Iā€™m just wondering how we access the max size of the array through the following syntax Array_name[0] through Array_name[Declared_Size-1] why do take the declared size and subtract 1? Iā€™m having a hard time understanding the logic behind it. I guess I could just accept it and use it when necessary but I would really like to understand the reasoning behind it.

14th Jun 2019, 8:23 PM
Anthony
2 Answers
+ 7
array indexing start from 0, so arr[10]--> last index will be arr[9] counting from zero to 9 will give you 10, you can't ommit count from zero that's why
14th Jun 2019, 8:59 PM
āœ³AsterisKāœ³
āœ³AsterisKāœ³ - avatar
+ 1
Because the index starts at 0
14th Jun 2019, 11:18 PM
Š’Š»Š°Š“ŠøŠ¼Šøр ŠŠ·Š°Ń€ŠµŠ½ŠŗŠ¾
Š’Š»Š°Š“ŠøŠ¼Šøр ŠŠ·Š°Ń€ŠµŠ½ŠŗŠ¾ - avatar