C Programming - Pointers - Discussion

Discussion Forum : Pointers - General Questions (Q.No. 6)
6.
What would be the equivalent pointer expression for referring the array element a[i][j][k][l]
((((a+i)+j)+k)+l)
*(*(*(*(a+i)+j)+k)+l)
(((a+i)+j)+k+l)
((a+i)+j+k+l)
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
70 comments Page 3 of 7.

Rajasimhan said:   1 decade ago
Let A[3][3] be a matrix.


A(address =50) --------> (address 60) ------>(address 100).
(address 61) ------>(address 103).
(address 62) ------>(address 106).

Now to get A[2][2] = *(*(*(50)+2)+2)
= *(*(60+2)+2)
= *(*(62)+2)
= *(106+2)
= *(108).

= value at address 108.

Aseil said:   1 decade ago
@Mark. I TRIED TO CLEAR IT BY THIS PROGRAM:

#include<stdio.h>

int main()

{
int a[2][2]={1,2,3,4};
printf("val address\n");
printf("%d %d\n",*(*(a)),*(a));
printf("%d %d\n",*(*(a)+1),*(a)+1);
printf("%d %d\n",*(*(a+1)),*(a+1));
printf("%d %d\n",*(*(a+1)+1),*(a+1)+1);

return 0;
}

Try to make some diagram to understand this and I am sure if you do so it will be clear.

Aswini .g said:   1 decade ago
Here a[0] = *(a+0).

a[0][1] = *(*(a+0)+1)).

Like wise k, l, m, n.

In orderly it follows become the answer.

Prasad said:   10 years ago
If you are passing value in expression through array then to fetch it require pointer and work on Stack mechanism and need to evaluate expression by Post order, or pre order.

Emanuel said:   9 years ago
It should be comes as *(a+i+j+k+l).

Baraka said:   8 years ago
Thanks @Ankit Jain.

Kuldeep said:   1 decade ago
As a[i] == *(a+i)
a[i][j]== *(*(a+i)+j))

Sowjanya said:   8 years ago
Thanks everyone for giving the clear answers.

Jaga said:   8 years ago
Nice explanation. Thank you all.

Raj said:   8 years ago
Pointer is the value which holds the address of another variable.


Post your comments here:

Your comments will be displayed after verification.