Bitwise OR in C – Why 4 | 2 Is 6 but 4 | 4 Is 4

Bitwise OR merges two bit patterns: a result bit is 1 if either operand has it. This question from our C Programming Quiz App uses two numbers whose bits don’t overlap — which makes OR behave exactly like addition, and that’s precisely what makes it a good test of whether you’re thinking in bits. The …

Equality Operator in C – Why 3 == 3 Prints 1, Not true

What does a comparison return in C? Not true. Not the compared value. A plain int — and this question from our C Programming Quiz App pins down exactly which one. It looks like the easiest question in the bank; the wrong options are where the learning is. The Quiz Question printf(“%d”, 3 == 3); …

Short-Circuit Evaluation in C – When || Must Evaluate 1/a

Everyone learns that || short-circuits — if the left side is true, the right side never runs. This question from our C Programming Quiz App tests the flip side people forget: when the left side is false, the right side must run. And here, the right side divides by zero. The Quiz Question int a …

Logical NOT in C – Why !0 Is 1 and ~0 Is -1

The logical NOT operator ! flips truth: true becomes false, false becomes true. Sounds trivial — until the options include -1 and you have to remember which NOT is which. This question from our C Programming Quiz App separates ! from its bitwise cousin ~. The Quiz Question int x = 0; printf(“%d”, !x); What …

Bitwise XOR in C – Why 5 ^ 3 Is 6 (and ^ Is Not Power)

Bitwise XOR — exclusive OR — keeps a bit only where the two operands differ. It’s the strangest of the bitwise trio at first sight, and the most magical once you know its two special properties. This question from our C Programming Quiz App starts with the arithmetic. The Quiz Question int a = 5; …