ProgrammingModerateGATE CS · TCS NQT

What does this C program print? unsigned char a = 200, b = 100; printf("%d %d", a + b > 255, (unsigned char)(a + b) > 255);

  1. A. 0 0
  2. B. 1 0
  3. C. 1 1
  4. D. 0 1

Correct answer: B. 1 0

In a + b both operands are promoted to int, so the sum is 300 and 300 > 255 is 1. Casting to unsigned char first wraps 300 to 44, and 44 > 255 is 0.

More C Programming questions

Exams that ask this topic