Let’s break this down step by step:
(i) To find the number of elements in each array, you can use the given array dimensions:
– AAA(5:50): This means AAA has elements from index 5 to 50. To find the number of elements, you subtract the lower bound from the upper bound and add 1 (to include both bounds). So, for AAA: 50 – 5 + 1 = 46 elements.
– BBB(-5:10): Similarly, for BBB: 10 – (-5) + 1 = 16 elements.
– CCC(18): Since CCC has only one index specified, it has a single element.
So, the number of elements in each array is:
– AAA: 46 elements
– BBB: 16 elements
– CCC: 1 element
(ii) To find the address of AAA[15], AAA[35], and AAA[55], you need to consider the base address and the word size:
– Base(AAA) = 300
– Word size (w) = 4 words per memory cell for AAA
To find the address of an element at index i in AAA, you can use the following formula:
Address(AAA[i]) = Base(AAA) + (i – lower bound) * word size
Let’s calculate the addresses:
– Address(AAA[15]) = 300 + (15 – 5) * 4 = 300 + 40 = 340
– Address(AAA[35]) = 300 + (35 – 5) * 4 = 300 + 120 = 420
– Address(AAA[55]) = 300 + (55 – 5) * 4 = 300 + 200 = 500
So, the addresses of AAA[15], AAA[35], and AAA[55] are 340, 420, and 500, respectively.