ProgrammingVery hardGATE CS · Campus placements

uint8_t x = 0x90; uint8_t y = x & (uint8_t)(x - 1); What is y?

  1. A. 0x90
  2. B. 0x8F
  3. C. 0x10
  4. D. 0x80

Correct answer: D. 0x80

x - 1 is 0x8F, and ANDing with 0x90 clears the lowest set bit, giving 0x80. This is the standard single-bit clear trick.

More C Programming questions

Exams that ask this topic