Calculate the address of a random element present in a 2D array, given base address as BA.
Share
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Row-Major Order: If the array is declared as a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in row-major order is calculated as,
Address(a[i][j]) = B. A. + (i * n + j) * size
Column-Major Order: If the array is declared as a[m][n] where m is the number of rows while n is the number of columns, then the address of an element a[i][j] of the array stored in column-major order is calculated as
Address(a[i][j]) = ((j*m)+i)*Size + BA.