Computer Science, asked by syedroshan5615, 10 months ago

Give the formula to calculate the memory address of an array element in 1D array

Answers

Answered by mayanksharma789594
5

Explanation:

Address of A [ I ] = B + W * ( I - LB )

Where,

B = Base address

W = Storage Size of one element stored in the array (in byte)

I = Subscript of element whose address is to be found

LB = Lower limit / Lower Bound of subscript, if not specified assume 0 (zero)

Example:

Given the base address of an array B[1300..1900] as 1020 and size of each element is 2 bytes in the memory. Find the address of B[1700].

Solution:

The given values are:

B = 1020, LB = 1300, W = 2, I = 1700

Address of A [ I ] = B + W * ( I - LB )

= 1020 + 2 * (1700 - 1300)

= 1020 + 2 * 400= 1020 + 800

= 1820 [Ans]

Answered by jrajeshshivam9p1i5qv
0

Answer:

Address of A [ I ] = B + W * ( I – LB )

= 1020 + 2 * (1700 – 1300)

= 1020 + 2 * 400

= 1020 + 800

= 1820

Similar questions