1. Home
  2. Computer Science MCQs
  3. C Programming
  4. In C, what does the logical AND operator do when its left…

Added 30 Nov -0001

In C, what does the logical AND operator do when its left operand is false?

  1. It raises a runtime fault on the expression
  2. It skips evaluating the right operand Correct answer
  3. It evaluates both operands and compares them
  4. It falls back to a bitwise AND on the bits

Correct answer

B. It skips evaluating the right operand

13 views

MCQSEXAM

Explanation

Short-circuit evaluation means the left operand of the logical AND decides the result on its own: when it is false the right side is never evaluated, so a guard that tests a pointer for NULL before dereferencing it cannot crash. The logical OR mirrors this by skipping the right side when the left is true. Because the skipped expression never runs, any side effect inside it, such as a function call or an increment, silently never happens.

Reference

Asked in: NTS, PPSC IT, Campus Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More C Programming MCQs

Practise all C Programming MCQs

Similar MCQs