मराठी

A Two Dimensional Array Arr[50][20] is Stored in the Memory Along the Row with Each of Its Elements Occupying 4 Bytes. Find the Address of the Element Arr[30] [10], If the Element Arr[10] [5] is Stored at the Memory Location 15000. - Computer Science (C++)

Advertisements
Advertisements

प्रश्न

A two-dimensional array ARR[50][20] is stored in the memory along the row with each of its elements occupying 4 bytes. Find the address of the element ARR[30] [10], if the element ARR[10] [5] is stored at the memory location 15000.

उत्तर

Loc(ARR[I][J]) along the row

=BaseAddress + W [( I – LBR) * C + (J – LBC)]
(where C is the number of columns, LBR = LBC = 0

LOC(ARR[10][5])

= BaseAddress + W [ I * C + J]
15000 = BaseAddress + 4[10*20 + 5]
= BaseAddress + 4[200 + 5]
= BaseAddress + 4 x 205
= BaseAddress + 820

BaseAddress = 15000 - ­820
= 14180

LOC(ARR[30][10])= 14180 + 4[30 * 20 + 10]
= 14180 + 4 * 610

= 14180 + 2440
= 16620

shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2014-2015 (March) All India Set 4
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×