18,846 views
5 5 votes
39 )

Suppose a multidimensional array is declared as m(2:8,-4:1,6:10). If the base address is 200 and there are 4 words per memory location, then the address of A[5,-1,8] by using row order is ______.

3 Answers

Best answer
9 9 votes

I have drawn a sketch of 3-D array to give a rough idea about how it looks like..it consists of many 2-D arrays also referred as Frames.

First see the no. of frames already crossed(given by the 1st dimension).. this means finding out how many elements of frames have already been covered. For that find (no. Of rows * no. Of columns)*no. Of frames given.

After reaching that particular frame, treat the sum as a simple 2-D array sum. 

• selected by
1 1 vote

answer  is very simple to find the address of multidimension array 

like in above problem if you go from left to right direction then  we find the adress of element in row major order  and if you are go from right to left direction then you find the address of element in column mjor order 

A[lb1......ub1][lb2.......ub2][lb3.......up3] is given array then 

Adress of the A[l][m][n]=base adress +[(l-lb1)(ub2-lb2+1)(ub3-lb3+1)+(m-lb2)(ub3-lb3+1)+n-lb3]*w

put the value and find the answer,anwer will come in this case 628

Position:
Show:

Related questions

0 0 votes
1 1 answer
662
662 views
jaikant asked Apr 14, 2023
662 views
I have confusion regarding pointers, why 1D array and 2D array works differently. For e.g. I have written a code#include <stdio.h>int main(){ int arr[6]={1,2,3,4,5,6};...
2 2 votes
0 0 answers
3.1k
3.1k views
Na462 asked Oct 20, 2018
3,124 views
What is the Output of following Array ? A. 8 10B. 10 8C. 10 2D. 8 1E. Garbage value
1 1 vote
1 answers 1 answer
2.8k
2.8k views
radha gogia asked Jul 10, 2018
2,817 views
If I have an array :int a [3][4] ; How to evaluate below Outputs ? 1. sizeof(*a) 2.sizeof( a) 3. sizeof(a) Please explain precisely .
4 4 votes
2 answers 2 answers
2.8k
2.8k views
Mayankprakash asked Jun 19, 2018
2,762 views
int main(){ char arr[5][7][6]; char (*p)[5][7][6] = &arr; /* Hint: &arr - is of type const pointer to an array of 5 two dimensional arrays of size [7][6] ...