🎙 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 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;
}
  1. A.even
  2. B.odd
  3. C.Compile error
  4. 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 →