← Quiz: Bitwise Operators in C: all 15 questions
Quiz: Bitwise Operators in C · Question 7 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
int x = 4;
if (x & 1 == 0)
printf("even");
else
printf("odd");
return 0;
}
- A.even
- B.odd
- C.Compile error
- D.Nothing
Answer & explanation
Correct answer: odd
== binds tighter than &, so this is x & (1 == 0) = 4 & 0 = 0, which is false. Write (x & 1) == 0.
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 →