At which index does the first element of a C++ array normally begin?
Options
- B. 1
- C. -1
- D. More than one of the above
- E. None of the above
Quiz Practice:
Answer: (A) 0
C++ arrays use zero-based indexing. Therefore, the first element is stored at index 0.
For an array:
int a[5];
the valid indexes are:
0, 1, 2, 3, 4
Thus, an array containing 5 elements has a last valid index of 4, not 5.