1,634 views
1 1 vote

Can anyone please verify whether I have calculated the addresses correctly or not?
 

 

1 Answer

3 3 votes
let array for column major order is a[layers][columns][rows]

base address is 100  and size of each element is 4 bytes

number of layers=-28-(-29)+1=2

number of columns -25-(-27)+1=3

number of rows=-21-(-24)+1=4

a-1=100-4*3*4=100-48=52

&a-1=100-4*4*3*2=100-96=4

a+2=100+2*(4*3*4)=100+96=196

&a+2=100+2*(4*2*3*4)=100+192=292

*a+3=100+3*(4*4)=100+48=148

&(*a)+3=a+3=100+3*(4*3*4)=100+144=244

*(*a)+3=100+3*4=100+12=112

*(a+3)+2=*(100+3*(4*3*4))+2=*(144)+2=144+4*2*4=144+32=176

**a+1=100+4*1=100+4=104

&(**a)+2=*a+2=100+4*2*4=100+32=132

&(***a)+3=**a+3=100+3*4=100+112
Position:
Show:

Related questions

1 1 vote
1 answers 1 answer
2.2k
2.2k views
Sahil Vidyarthi asked Aug 23, 2014
2,214 views
Explain the output :-int b[3][4] = {{1,2,3,4}, {5,6,7,8}, {9,10,11,12}};int p;p = (int )b;cout << (long)*p << "\t" << (long)(*p+1) << "\t" << (long)(*p+2);//long is used...
13 13 votes
8 answers 8 answers
9.2k
9.2k views
Na462 asked Aug 22, 2018
9,233 views
Consider a 2 dimensional array A[40...95,40...95] in lower triangular matrix representation. The size of each element of array is 1 Byte.If array is implemented in memory...
1 1 vote
1 1 answer
610
610 views
Pankaj Joshi asked Jan 25, 2017
610 views