The number of elements in a one-dimensional array with lowest and highest…

2017

The number of elements in a one-dimensional array with lowest and highest index values as -1024 and 1024 is:

  1. A.

    2048

  2. B.

    0

  3. C.

    1024

  4. D.

    2049

Attempted by 594 students.

Show answer & explanation

Correct answer: D

The number of elements in a 1D array is calculated using the formula: Upper Bound (UB) - Lower Bound (LB) + 1. Given UB = 1024 and LB = -1024, the total elements are 1024 - (-1024) + 1 = 2048 + 1 = 2049. Thus, Option D is correct.

Explore the full course: Niacl Ao It Specialist