← Quiz: Bitwise Operators in C: all 15 questions
Quiz: Bitwise Operators in C · Question 4 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
unsigned n = 29;
int c = 0;
while (n) { n &= n - 1; c++; }
printf("%d", c);
return 0;
}
- A.4
- B.3
- C.5
- D.29
Answer & explanation
Correct answer: 4
29 is 11101, which has four 1s; each pass removes one.
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 →