With && and ||, C evaluates the left operand first, and only evaluates the right operand if the result isn't yet determined. For &&, if the left side is false, the right side is skipped, the whole expression must be false. For ||, if the left side is true, the right side is skipped. This isn't just performance. It lets you guard a dangerous operation: if (p != NULL && *p > 0) will never dereference p when it's null, because && skips the right side. With the bitwise & (which does not short-circuit), both sides would always run and you'd crash.
Programming Fundamentals · Interview question
What does short-circuit evaluation mean, and why does it matter?
A strong answer
What a weak answer sounds like
You know the answer. Do you know what gets you dinged?
Pro breaks down the answer most candidates actually give to this question — and the specific reason an interviewer marks it down. It’s the difference between sounding correct and sounding senior, on all 472 questions.
From the lesson
Operators
Everything between the variables: the symbols that combine, compare, and change values. Learn the four families and the precedence rules that bite.