Which of the following C statements can also be used in place of num[i]? (i)…
2018
Which of the following C statements can also be used in place of num[i]?
(i) *(num + i )
(ii) i[num]
(iii) *(i+num)
- A.
Only (ii)
- B.
(i), (ii) and (iii)
- C.
Only (i)
- D.
Only (iii)
Attempted by 96 students.
Show answer & explanation
Correct answer: B
The correct option is B. In C, array subscripting num[i] is internally evaluated using pointer arithmetic as *(num + i). Because addition is commutative, *(num + i) is identical to *(i + num), which can also be written in subscript form as i[num]. Therefore, all three expressions are completely valid and equivalent.