201k views
1 vote
Let's say we have an array of shorts. Each short occupies 2 bytes in memory. If this array begins at address 112268 , what is the address of element 215 ?

User Wednesday
by
7.1k points

1 Answer

3 votes

Final answer:

To find the address of the 215th element in an array starting at address 112268, calculate it as: base address plus (element index times element size in bytes). Since each short is 2 bytes, the address is 112268 + (215 * 2) = 112698.

Step-by-step explanation:

To find the address of the 215th element in an array where each short occupies 2 bytes, you can use the formula:

Address of element[i] = Base address + (i * size of each element)

In this case, the base address is 112268, and the size of each element (short) is 2 bytes. To find the address of the 215th element:

Address of element[215] = 112268 + (215 * 2)

Performing the calculation:

Address of element[215] = 112268 + 430 = 112698

Therefore, the address of the 215th element in the array is 112698.

User Toma
by
7.7k points