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)

  1. A.

    Only (ii)

  2. B.

    (i), (ii) and (iii)

  3. C.

    Only (i)

  4. 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.

Explore the full course: Btsc Lab Assistant