recategorized by
9,567 views
6 votes
6 votes

Consider a $2$-dimensional array $x$ with $10$ rows and $4$ columns, with each element storing a value equivalent to the product of row number and column number. The array is stored in row-major format. If the first element $x[0][0]$ occupies the memory location with address $1000$ and each element occupies only one memory location, which all locations (in decimal) will be holding a value of $10$?

  1. $1018,1019$
  2. $1022,1041$
  3. $1013,1014$
  4. $1000,1399$
recategorized by

6 Answers

5 votes
5 votes
we can only get 10 from following combinations:

1*10 -- NOT POSSIBLE

10*1 -- POSSIBLE(take combination x[9][0])

2*5 --NOT POSSIBLE

5*2 -- POSSIBLE (x[4][1])

 

x[9][0] = 9*4+0+1000 = 1036

x[4][1]=4*4+1+1000=1017

I think this can be one of the answers
2 votes
2 votes
Option B is correct

10 = 10*1,5*2

      =1*10,2*5  is not possible because maximum 4 column

So

X[10]*[1]=1000+1[4(10-0)+(1-0)]

               =1000+41=1041

X[5]*[2]=1000+1[4(5-0)+(2-0)]

           =   1000  +22=1022
0 votes
0 votes

Since each cell of 2D array say A[10][4] storing a value equivalent to the product of row number and column number...

.

For a location(cell) to hold a value of 10 the row and column must be of the form 1*10, 10*1, 2*5 or 5*2...

.

From these 4 values of rows and columns we can eliminate 1*10 and 2*5 as these values are falling out of the given array data... As value of column is >4 

.

So now we have to find the position for 10*1 and 5*2...

As BA for A(0)(0) is 1000...

Address for 10*1 = 1000+9*4+1 =1037

Address for 5*2 = 1000+ 4*4+ 2 = 1018

.

So answer should be 1018 and 1037 which is not in any option...

0 votes
0 votes
I got the 1018 and 1037 address  

in the problem, 10 will appear only  2 times that is x[1][10] and x[2][5]

x[1][10] = 1037
x[2][5] = 1018
Answer:

Related questions

6 votes
6 votes
5 answers
1
Satbir asked Jan 13, 2020
3,715 views
What is the output of the code given below?# include<stdio.h int main() { char name[]="satellites"; int len; int size; len= strlen(name); size = sizeof(name); printf("%d"...
2 votes
2 votes
3 answers
2
Satbir asked Jan 13, 2020
1,786 views
Consider the following recursive C function that takes two argumentsunsigned int rer(unsigned int n, unsigned int r){ if(n>0)return(n%r + rer(n/r,r)); else retturn 0; }Wh...
6 votes
6 votes
1 answer
3