3,120 views
8 votes
8 votes

(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 Answer

Best answer
14 votes
14 votes

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.

 

for clarity image https://drive.google.com/open?id=1xGGZKaGH582n_aqwWOgyeGssxpYdjuRB

 

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

selected by

Related questions

4 votes
4 votes
0 answers
1