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