ProgrammingModerateTCS NQT · Wipro

With int a[3], *p = a; which statement fails to compile?

  1. A. p = a + 2;
  2. B. a++;
  3. C. p++;
  4. D. *(a + 1) = 5;

Correct answer: B. a++;

An array name converts to a pointer value in expressions, but the array itself is not a modifiable lvalue, so a++ is rejected. p is an ordinary pointer variable, and a + 1 is a fine expression to dereference.

More C Programming questions

Exams that ask this topic