ProgrammingHardGATE CS · Campus placements

int *q = NULL; if (q != NULL && *q == 3) printf("yes"); else printf("no"); What is printed?

  1. A. yes
  2. B. no
  3. C. crash
  4. D. undefined

Correct answer: B. no

The && operator short-circuits, so *q is never evaluated when q is NULL. The else branch runs and prints no.

More C Programming questions

Exams that ask this topic