🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Bitwise Operators in C: questions with answers

15 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does this print? (code)
  2. Q2. What is the value of ~7 on a two's complement machine?
  3. Q3. Which expression clears bit 3 of x?
  4. Q4. What does this print? (code)
  5. Q5. Why does (n & (n - 1)) == 0 (with n 0) mean n is a power of two?
  6. Q6. What is 5 << 3?
  7. Q7. What does this print? (code)
  8. Q8. Every number in an array appears twice except one. Which operation finds the single one in O(n) time and O(1) space?
  9. Q9. What is 2 ^ 3 in C?
  10. Q10. Which statement about bit-fields is true?
  11. Q11. What does this print? (code)
  12. Q12. What does this print? (code)
  13. Q13. What does (x k) & 1 give?
  14. Q14. Which expression flips (toggles) bit 2 of x, leaving the other bits unchanged?
  15. Q15. What does this print? (code)