+ 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.
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
+ 1
Because the index starts at 0