ProgrammingVery hardGATE CS · Campus placements

unsigned int u = 5u; int s = -5; printf("%s", (u + s == 0) ? "yes" : "no"); What is printed?

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

Correct answer: A. yes

s is converted to unsigned, giving 2^32 - 5, and 5 + (2^32 - 5) wraps to 0. The comparison is therefore true.

More C Programming questions

Exams that ask this topic