Which formula represents the address of the element A[i] in a zero-based one-dimensional array?

Options

  • A. Base + i * w
  • B. Base + (i - 1) * w
  • C. Base + i + w
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

A. Base + i * w

Detailed Explanation

Correct Answer: A. Base + i * w

Explanation: For a zero-based array, the address of A[i] is calculated as:

Address(A[i]) = Base Address + (i * w)

  • Base Address = address of the first element.
  • i = index of the required element.
  • w = size of each element in bytes.

Example: If Base = 1000, i = 3 and w = 4, address = 1012.