ProgrammingHard

unsigned v = 12; printf("%u", v & -v); What is printed?

  1. A. 12
  2. B. 8
  3. C. 4
  4. D. 1

Correct answer: C. 4

For unsigned v, -v is the two's complement wrap, and v & -v isolates the lowest set bit of 12, which is 4.

More C Programming questions

Exams that ask this topic