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];
}
- A.
q-p
- B.
p+1
- C.
q-3
- D.
p+q
Attempted by 304 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.