ProgrammingModerateWipro · Capgemini pattern

What is printed?

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

Correct answer: A. 4

unsigned char holds 0–255 and unsigned arithmetic wraps modulo 256. 250 + 10 = 260 is computed in int, then stored back as 260 mod 256 = 4. The wrap is well-defined for unsigned types.

More C Programming questions

Exams that ask this topic