In an array declared as int a[5];, the valid indices are:
Correct answer
B. 0 to 4
11 views
B. 0 to 4
11 views
Array indices start at 0, so a 5-element array has indices 0, 1, 2, 3, 4. Using index 5 would go out of bounds and cause undefined behaviour. This off-by-one error is very common.
Asked in: Matric,FBISE
Not sure why the answer is B? Ask here and get an explanation.