ProgrammingHardTCS NQT · Infosys

unsigned int u = 3; int s = -4; printf("%d", (int)u + s); What is printed?

  1. A. -1
  2. B. -7
  3. C. 2
  4. D. 9

Correct answer: A. -1

(int)u is 3, so 3 + (-4) is -1 with no unsigned conversion involved. A mixed unsigned and signed sum would give a very different value.

More C Programming questions

Exams that ask this topic