ProgrammingVery hardCognizant GenC · C · Advanced

What is printed?

What is printed?
unsigned char a = 250, b = 10;
printf("%d %d", (a + b) > 255, (unsigned char)(a + b));
  1. A. 0 4
  2. B. 1 260
  3. C. 1 4
  4. D. 0 260

Correct answer: C. 1 4

Both operands are promoted to int, so a + b is 260 and 260 > 255 is true; the cast to unsigned char wraps 260 to 4.

More C Programming questions

Exams that ask this topic