Q: A single dimensional array has 50 elements, which of the following is the correct statement to initialize the last element to 100.
-
A
x[51] = 100
-
B
x[48] = 100
-
C
x[49] = 100
-
D
x[50] = 100
C
Answer:
C
Explanation:
Given:
Step 1: Determine last index
Remember: last index = total elements − 1
Step 2: Match with options
(a) x[51] = 100 → ❌ Out of bounds
(b) x[48] = 100 → ❌ 49th element, not last
(c) x[49] = 100 → ✅ Correct, last element
(d) x[50] = 100 → ❌ Out of bounds
✅ Answer: (c) x[49] = 100
Related Topic:
Share Above MCQ