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:
- A.
2048
- B.
0
- C.
1024
- 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.