Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

ISRO | ISRO CS 2020 | Question 80

  • Difficulty Level : Basic
  • Last Updated : 09 Aug, 2021

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 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 ?
(A) 1018, 1019
(B) 1022, 1041
(C) 1013, 1014
(D) 1000, 1399


Answer: (B)

Explanation: Let’s visualize this question by actual a matrix of 10×4, now to achieve value of ’10’ as per the condition of ‘each element storing a value equivalent to the product of row number and column number’, X[1][10] and X[5][2] are the only possible combination which will happen.

So keeping those in mind as X[0][0] holds address of 1000, for X[1][10] and X[5][2], we’ll get two different addresses so let’s find out for X[1][10], As the array is stored in row-major format, We have to travel 10 rows of 4 columns from the base address and then in that row travel 1 columns get the required location, which is mathematically, X[10]*[1]=1000+1[4(10-0)+(1-0)]=1000+41=1041 And same way for X[5][2], calculation will be,

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

So the answer is 1022 & 1041.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :