0
0
Cprogramming~20 mins

Bit manipulation techniques - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Bitwise Master
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?
C
int a = 12;  // binary: 1100
int b = 10;  // binary: 1010
int c = a & b;
printf("%d", c);
A8
B14
C2
D10
Attempts:
2 left
💡 Hint
Remember that & compares bits and returns 1 only if both bits are 1.
Predict Output
intermediate
2:00remaining
Output of left shift operation
What will be printed by this C code?
C
unsigned int x = 5;  // binary: 0000 0101
unsigned int y = x << 2;
printf("%u", y);
A10
B2
C20
D40
Attempts:
2 left
💡 Hint
Left shift by 2 means multiply by 2 twice (4 times).
Predict Output
advanced
2:00remaining
Output of toggling bits using XOR
What is the output of this C code snippet?
C
int num = 29;  // binary: 0001 1101
int mask = 15; // binary: 0000 1111
int result = num ^ mask;
printf("%d", result);
A18
B14
C12
D31
Attempts:
2 left
💡 Hint
XOR flips bits where mask has 1s.
Predict Output
advanced
2:00remaining
Output of checking if a number is a power of two
What does this C code print?
C
int n = 16;
int check = (n & (n - 1)) == 0;
printf("%d", check);
A16
B0
C1
D15
Attempts:
2 left
💡 Hint
A power of two has only one bit set.
Predict Output
expert
2:00remaining
Output of clearing the rightmost set bit
What is the output of this C code?
C
int x = 44;  // binary: 0010 1100
int y = x & (x - 1);
printf("%d", y);
A44
B40
C12
D32
Attempts:
2 left
💡 Hint
x & (x-1) clears the rightmost set bit.