Challenge - 5 Problems
Bitwise Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of bitwise AND operation
What is the output of this C code snippet?
C
int a = 12; // binary: 1100 int b = 10; // binary: 1010 int c = a & b; printf("%d", c);
Attempts:
2 left
💡 Hint
Think about how bitwise AND works on each bit.
✗ Incorrect
Bitwise AND compares each bit of two numbers. Only bits set in both numbers remain set. 1100 & 1010 = 1000 in binary, which is 8 in decimal.
🧠 Conceptual
intermediate1:30remaining
Why use bitwise operations?
Which of the following is the main reason programmers use bitwise operations?
Attempts:
2 left
💡 Hint
Think about what bitwise operations allow you to control at the smallest level.
✗ Incorrect
Bitwise operations let programmers change or check individual bits, which helps save memory and speed up programs, especially in low-level programming.
❓ Predict Output
advanced2:00remaining
Output of bitwise shift operations
What is the output of this C code?
C
unsigned int x = 5; // binary: 0000 0101 unsigned int y = x << 2; printf("%u", y);
Attempts:
2 left
💡 Hint
Left shift by 2 means multiply by 4.
✗ Incorrect
Left shifting 5 (binary 0101) by 2 bits moves bits left twice, equivalent to multiplying by 4. So 5 * 4 = 20.
❓ Predict Output
advanced2:00remaining
Result of bitwise XOR operation
What does this C code print?
C
int a = 9; // binary: 1001 int b = 14; // binary: 1110 int c = a ^ b; printf("%d", c);
Attempts:
2 left
💡 Hint
XOR sets bits where bits differ.
✗ Incorrect
XOR compares bits and sets the bit to 1 only if bits differ. 1001 ^ 1110 = 0111 in binary, which is 7 decimal.
🧠 Conceptual
expert2:30remaining
Why bitwise operations are critical in embedded systems
Why are bitwise operations especially important in embedded systems programming?
Attempts:
2 left
💡 Hint
Think about the hardware constraints of embedded devices.
✗ Incorrect
Embedded systems usually have limited memory and processing power. Bitwise operations allow precise control of hardware registers and efficient resource use.