ProgrammingHardProduct-company MCQ pattern

What is printed?

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

Correct answer: D. 4 255 260

a + b is computed in int after integer promotion (260), so s keeps 260. Storing it back in an unsigned char reduces it mod 256 → 4. Decrementing an unsigned char 0 wraps to 255; unsigned arithmetic wrap-around is well defined.

More C Programming questions

Exams that ask this topic