Skip to main content
C Output Prediction Hard +35 XP

Bitwise AND

What is the result?

CRead-only
int a = 12;  // 1100 in binary
int b = 10;  // 1010 in binary
printf("%d", a & b);

What is the output?

Show answer and explanation

Answer: 8

12 & 10: 1100 & 1010 = 1000 = 8. Bitwise AND only sets bits where both operands have 1.

Hint: AND only keeps bits that are 1 in BOTH numbers.

What this challenge tests

Output Prediction in C: bitwise, binary.

Related challenges