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!