Question 44 Which one of the statement given in options is correct about 10 used in the...
Qualcomm technical mcq question, verified with a worked answer. Free to practise - no sign-up.
Question 44
Which one of the statement given in options is correct about 10 used in the following C expression?
int arr[10];
arr[10] = 25;
Show answer & explanation
Answer: B. In the first statement 10 specifies the array size, whereas in the second statement it specifies a particular element of the array.
In int arr[10];, the 10 inside square brackets declares the array size—allocating space for 10 elements indexed 0–9. In arr[10] = 25;, the 10 is an array subscript (index) attempting to access the element at position 10, which is actually out of bounds (undefined behavior in C). The 10 changes meaning contextually: declaration syntax vs. runtime subscript operation.
Step-by-step Derivation:
Declaration vs. Access:
int arr[10];— This is a declaration. The 10 specifies how many elements the array will hold (size = 10).arr[10] = 25;— This is an array access operation. The 10 is the subscript/index used to access a specific element. Valid indices for arr are 0–9; index 10 is out of bounds.
Compare each option:
- A: Reverses the roles (10 specifies element in first, size in second) — Incorrect.
- B: Correctly identifies 10 as size in first statement and element subscript in second — Correct.
- C: Incorrectly claims array size changes dynamically; C arrays are fixed-size — Incorrect.
- D: Incorrectly claims 10 specifies a type — Incorrect.
Answer: B