🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Bitwise Operators in C: all 15 questions

Quiz: Bitwise Operators in C · Question 14 of 15

Which expression flips (toggles) bit 2 of x, leaving the other bits unchanged?

Which expression flips (toggles) bit 2 of x, leaving the other bits unchanged?

  1. A.x | (1 << 2)
  2. B.x & ~(1 << 2)
  3. C.x ^ (1 << 2)
  4. D.x >> 2
Answer & explanation

Correct answer: x ^ (1 << 2)

XOR with 1 flips a bit and XOR with 0 keeps it; | sets the bit and & ~ clears it.

Can you get the rest right without peeking?

Take the timed Quiz: Bitwise Operators in C quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →