0
0
Cprogramming~20 mins

Bitwise AND, OR, XOR in C - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bitwise Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Bitwise AND Operation
What is the output of the following C code snippet?
C
int a = 12;  // binary: 1100
int b = 10;  // binary: 1010
int c = a & b;
printf("%d", c);
A2
B8
C10
D4
Attempts:
2 left
💡 Hint
Remember that bitwise AND compares each bit of two numbers and returns 1 only if both bits are 1.
Predict Output
intermediate
2:00remaining
Output of Bitwise OR Operation
What is the output of this C code?
C
int x = 5;  // binary: 0101
int y = 3;  // binary: 0011
int z = x | y;
printf("%d", z);
A7
B1
C6
D8
Attempts:
2 left
💡 Hint
Bitwise OR returns 1 if either bit is 1.
Predict Output
advanced
2:00remaining
Output of Bitwise XOR Operation
What will this C program print?
C
int a = 9;  // binary: 1001
int b = 14; // binary: 1110
int c = a ^ b;
printf("%d", c);
A7
B15
C5
D3
Attempts:
2 left
💡 Hint
XOR returns 1 only if bits differ.
Predict Output
advanced
2:00remaining
Result of Combined Bitwise Operations
What is the output of this code?
C
int a = 6;  // binary: 0110
int b = 11; // binary: 1011
int c = (a & b) | (a ^ b);
printf("%d", c);
A7
B9
C5
D15
Attempts:
2 left
💡 Hint
Calculate AND and XOR separately, then OR the results.
Predict Output
expert
3:00remaining
Bitwise Operation with Negative Numbers
What is the output of this C code snippet?
C
int a = -5;  // in two's complement
int b = 3;
int c = a & b;
printf("%d", c);
A1
B0
C3
D-5
Attempts:
2 left
💡 Hint
Remember how negative numbers are stored in two's complement and how bitwise AND works.