The index of array, which is of the form a[i], is converted by the compiler in the form [a+i]. So, the index of first element is zero because [a+0] will give ‘a’ & the first array element can be accessed. Due to this, we can also access the array elements as’i[a]‘ instead of ‘a[i]‘ , &
this will not produce an error.
More so, because the Binary Count used by Computers always starts from 0. Lets say we have a 3 bit value.
It’ll be something of this sought,
000 –> 0
001 –> 1 and so on .. .
it is due to the ease of calculation that our compiler do in calculating the addtess is nth index….
(start add.)+index*sizeof(int)…if it nis an integer array…
for first-index=0;
for 2nd index=1;
The index of array, which is of the form a[i], is converted by the compiler in the form [a+i]. So, the index of first element is zero because [a+0] will give ‘a’ & the first array element can be accessed. Due to this, we can also access the array elements as’i[a]‘ instead of ‘a[i]‘ , &
this will not produce an error.
More so, because the Binary Count used by Computers always starts from 0. Lets say we have a 3 bit value.
It’ll be something of this sought,
000 –> 0
001 –> 1 and so on .. .
it is due to the ease of calculation that our compiler do in calculating the addtess is nth index….
(start add.)+index*sizeof(int)…if it nis an integer array…
for first-index=0;
for 2nd index=1;