648 views
1 votes
1 votes
Int main()

{

unsigned int x[4][3]={{1,2,3},{4,5,6},{7,8,9},{10,11,12}}

Printf("%u%u%u",x+3,*(x+3),*(x+2)+3);

}

Assume that address of x is 2000

And intrger requires four byte of memory

Answer is 2036,2036,2036

My question is why *(x+3) give address of that location .why not value which present at that location.and please suggest some good source to learn about this concept

2 Answers

Best answer
4 votes
4 votes
  • When i said print (X) then it print 2000

  • When i said print (*X )then it also print 2000.

But both have diffreant meaning 

X ---> it give the base address 

*X --->it will also give base address but it select that row.

Now look at some example

  • X+1----> skeeping one row and it gives 2012
  • *x+1 ---> at first select that row and skeep one element . So this will give 2004
  • **X+1 -----> at first select that row after select that element and add one .so this wil give 1+1 =2

Simillary we can solve above question

 

 

selected by
1 votes
1 votes

as here x is 2 D array of 4 rows and three columns,we will use row major order by default if it is not given anything.

so here is the solution-