ProgrammingVery hard

int n = -1; if (n < strlen("abc")) puts("yes"); else puts("no"); What is printed?

  1. A. no
  2. B. yes
  3. C. undefined behaviour
  4. D. compile error

Correct answer: A. no

n is converted to size_t, a huge unsigned value, so n < 3 is false. The comparison is well defined and quietly wrong.

More C Programming questions

Exams that ask this topic