Slideshow

Monday 25 February 2013


Consider a 2D array as char A[5] [6] stored in contiguous memory locations
starting from location 1000” in column major order. What would the address of
a[i] [d]? 

Ans:
Considering the given char array A[5][6] stored in contiguous memory in column
major order; the address of a[i] [d] would be calculated as
base (a) + (d*n1 +i) * size ; where base(a) =1000 (given).
Since it is a char array so size=1 and n1 is the total no of rows
here n1=6 (0,1,2,3,4,5,) Substituting values we get the address of
A[i] [d] = 1000 + d*6 + i

No comments:

Post a Comment