2,325 views

(int *) a means the base address of the array a ,(int *) a+1 means the address of 2nd element in the array. or base address of 2nd row of the array ? please clear this doubt i am facing problems in these type of question or if anyone knows basics of these types problems please explain that one. 1. 1, 1, 1, 1
2, 2, 2, 2
3, 3, 3, 3
2, 2, 2, 2
3, 3, 3, 3
4, 4, 4, 4 1, 1, 1, 1
2, 3, 2, 3
3, 3, 3, 3
2, 3, 2, 3
3, 3, 3, 3
4, 4, 4, 4
2. 1, 1, 1, 1
2, 4, 2, 4
3, 3, 3, 3
2, 4, 2, 4
3, 3, 3, 3
4, 4, 4, 4
3.  1, 1, 1, 1
2, 4, 2, 4
3, 0, 3, 0
4, 2, 4, 2
5, 5, 5, 5
6, 0, 6, 0

### 1 comment

Plz explain for

i = 1,  j=0

i. = 1 , j= 1

i.  = 1,  j= 2

I am not understand plz explain??

let int *p = &i;

what it means, address of the integer i is stored in the p. ===> value of p = address of i.

∴ if you use p to require value, then it gives the address of the integer i.

ARR is a two dimensional array.

therefore it is a collection of 1-D array's. when you specified as value of ARR then it returns the base address of 1-D array. Note that, *(*(p+i)+j) = p[i][j]; and *(*(p+j)+i) = p[j][i];

when i=0

when j=0 ===> the printf function prints 1,1,1,1

when j=1 ===> the printf function prints 2,2,2,2

when j=2 ===> the printf function prints 3,3,3,3

when i=1

when j=0 ===> the printf function prints 2,2,2,2

when j=1 ===> the printf function prints 3,3,3,3

when j=2 ===> the printf function prints 4,4,4,4

you said that :

*(*(p+i)+j) = p[i][j]; and *(*(p+j)+i) = p[j][i];

but if we take i=0,j=1  than p=2 is not equal to p=4 thus the  answer should be 2,4,2,4 than why the answer is 2,2,2,2 please explain
You mistaken while understanding what is p.

Very well explained @ShaikMasthan

If in question like below

static int *p[]={a,a+1,a+2};

then

output like below

1 1 1 1
2 4 2 4
3 garbage 3 garbage
4 2 4 2
5 5 5 5
6 garbage 6 garbage

Please, correct if I am wrong.