1 1 vote Can anyone please verify whether I have calculated the addresses correctly or not? Programming in C pointers programming array + – Balaji Jegan 1.6k views answer comment Share Follow Print See 1 comment 1 1 comment reply Shaik Masthan commented Jun 28, 2018 reply Follow flag first write how your elements look like in memory... then verify your answers... I hope you did wrong.. your elements in memory look like as ( for better understanding take one more 2D array ) 000 010 020 100 110 120 *** 200 210 220 001 011 021 101 111 121 *** 201 211 221 002 012 022 102 112 122 *** 202 212 222 003 013 023 103 113 123 *** 203 213 223 and now give the addresses.. 000 get 100, 010 get 104.... 0 0 replyShare Please log in or register to add a comment.
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 Anil Ji answered Jun 28, 2018 Anil Ji comment Share Follow See all 2 Comments 2 2 Comments reply James Kurakula commented Feb 1, 2020 reply Follow flag &(**a)+2= 136? 0 0 replyShare James Kurakula commented Feb 1, 2020 reply Follow flag *(a+3)+2=268? 0 0 replyShare Please log in or register to add a comment.