Multiple choice

What will be the output of the following function?

main() { printf(%x,-1<<4); }

  1. 1111111111110

  2. -1

  3. fff0

  4. None of these

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In a 16-bit system, -1 is represented as 0xFFFF in two's complement. Shifting this value left by 4 bits results in 0xFFF0, which is printed as fff0 by the %x format specifier.