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
APPEARS IN
संबंधित प्रश्न
Write the definition of a function SumEO(int VALUES[], int N) in C++, which should display the 4 sum of even value and sum of odd values of the array separately.
Example: If the array VALUES contains
25 | 20 | 22 | 21 | 53 |
Then the functions should display the output as:
Sum of even values = 42 (i.e., 20+22)
Sum of odd values= 99 (i.e., 25+21+53)
Write a definition for a function UpperHalf(int Mat[4][4]) in C++ which displays the elements in the same way as per the example is shown below.
For example, if the content of the array Mat is as follows:
25 | 24 | 23 | 22 |
20 | 19 | 18 | 17 |
15 | 14 | 13 | 12 |
10 | 9 | 8 | 7 |
Thew function should display the content in the following format:
Let us assume Data[20][15] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 2 bytes. Find the address of the element Data(10][5], if the element Data[10][l5] is stored at the memory location 15000.
ARR[15] ft:20] is a two-dimensional array, which is stored in the memory along the row with each of its elements occupying 4 .bytes. Find the .address of the element ARR[5)[15], if the element ARR[lO] [5] is stored at the memory location 35000.
Write a function REVROW(int P[] [5], int N, int M) in C++ to display the content of a two-dimensional array, with each row content in reverse order.
For example, if the content of the array is as follows:
15 | 12 | 56 | 45 | 51 |
13 | 91 | 92 | 87 | 63 |
11 | 23 | 61 | 46 | 81 |
The function should display output as