ProgrammingHardTCS NQT · Infosys

unsigned char c = 0x7F; c = c * 2 + 2; What is c?

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

Correct answer: A. 0

c * 2 + 2 is 256 in int, and storing 256 into an unsigned char keeps 256 mod 256 = 0. The assignment is well defined.

More C Programming questions

Exams that ask this topic