← Quiz: Bitwise Operators in C: all 15 questions
Quiz: Bitwise Operators in C · Question 15 of 15
What does this print? (code)
What does this print?
#include <stdio.h>
int main(void) {
printf("%d %d\n", 2 & 1, 2 && 1);
return 0;
}
- A.1 1
- B.0 0
- C.0 1
- D.2 1
Answer & explanation
Correct answer: 0 1
2 is 10 and 1 is 01 in binary, so 2 & 1 is 0. 2 && 1 is a logical test: both are non-zero, so it is 1.
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 →