LearnFrenzy
Sign in Take a free test

Bitwise Operators · Bitwise Operators MCQ · Question 12

Integer promotion: ~ on an unsigned char Answer, explanation & discussion

  • MCQ
  • Hard
  • 0 comments
  • Answer explained
  • Moderated community
Question 12 Back to Exercise

For unsigned char c = 0x0F;, what are the type and value of ~c?

  • A unsigned char, 0xF0 (240)
  • B int, -16 Correct
  • C unsigned int, 0xF0
  • D char, -16
Correct Answer: Option B

Before ~ is applied, c is promoted to int (0x0000000F). Flipping all 32 bits gives 0xFFFFFFF0, which as an int is −16. Cast back – (unsigned char) ~c – to get 240.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links