ProgrammingHardProduct company OA

Assume 8-bit unsigned char. What is printed?

Assume 8-bit unsigned char. What is printed?
int i; unsigned char c; double d;
d = c = i = 300 + 0.7;
printf("%d %d %.1f", i, c, d);
  1. A. 300 44 300.7
  2. B. 300 44 300.0
  3. C. 300 44 44.0
  4. D. 301 45 45.0

Correct answer: C. 300 44 44.0

Assignment groups right to left and each step converts to the target's type. i gets 300.7 truncated to 300; c gets 300 mod 256 = 44; d gets c's value, 44.0. The chain does not pass 300.7 to every variable.

More C Programming questions

Exams that ask this topic