ProgrammingHardGATE CS · Campus placements

unsigned char c = 0xF0; printf("%d", ~c); prints what?

  1. A. 15
  2. B. -241
  3. C. -16
  4. D. 4294967055

Correct answer: B. -241

c is promoted to int with value 240, and bitwise NOT on that int gives -241 in two's complement. Printing with %u would instead show 4294967055, and the unsigned char itself never holds a negative value.

More C Programming questions

Exams that ask this topic