Which of the following statements is INCORRECT with respect to pointers…

2017

Which of the following statements is INCORRECT with respect to pointers declared in the following ‘C’ code?

void main()

{

int a[10], *p, *q;

p = &a[5];

q = &a[7];

}

Answer: D. p+qIn C, pointer arithmetic allows subtracting two pointers (q - p) or adding/subtracting an integer to/from a pointer (p + 1, q - 3). However, adding two…

  1. A.

    q-p

  2. B.

    p+1

  3. C.

    q-3

  4. D.

    p+q

Attempted by 514 students.

Show answer & explanation

Correct answer: D

In C, pointer arithmetic allows subtracting two pointers (q - p) or adding/subtracting an integer to/from a pointer (p + 1, q - 3). However, adding two pointers (p + q) is geometrically meaningless and syntactically invalid because it results in an illegal memory address, causing a compilation error.

Thus, the incorrect statement (correct option) is D.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…