Only legal pointer operations: (A) pointer + number → pointer (B) pointer –…

2025

Only legal pointer operations:
(A) pointer + number → pointer
(B) pointer – number → number
(C) pointer + pointer → pointer
(D) pointer - pointer → pointer
(E) pointer – pointer → number
Choose the most appropriate answer from the options given below:

  1. A.

    A, B, C Only

  2. B.

    A, B, D Only

  3. C.

    A, B Only

  4. D.

    A, E Only

Attempted by 402 students.

Show answer & explanation

Correct answer: D

Correct legal pointer operations:

  • pointer + number → pointer — Adding an integer offset to a pointer yields another pointer.

  • pointer − pointer → number — Subtracting two pointers yields the difference as an integer type (ptrdiff_t).

Why the other listed operations are not legal:

  • pointer − number does not yield a plain number; it yields a pointer (you can subtract an integer from a pointer to get another pointer).

  • pointer + pointer is not allowed in C/C++.

Therefore, the correct answer is the choice that lists exactly: pointer + number → pointer and pointer − pointer → number.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor