+ 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 Respostas
+ 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