Let the base address of an array a[10] be 1000. So, if you want to access the element in index 2 of the array a, you write a[2]. The interpretation of this statement according to the compiler is:
a[2]= 1000 + (2 * 2) = 1004
Thus you access any element by the formula :
a[index]= base_address + (sizeof datatype * index no)
Now, coming to your question, when you give only the name of the array as in ai
in your case, you are actually passing the base address of the array. This is the reason you are using the pointer sign in the function parameter.int *arry, int index
.
You must be knowing the following :
int a,*b,c;
a=8;
b=&a;
c=*b;
When you print c, you will get 8.
Hence, if index is 2, the line arry[index]
is interpreted as :
(base_address) + (sizeof int * 2)