Machine-translated by Google. Questions are authored in English.
Top

Discussion

Are logical operators in C evaluated with short-circuit evaluation?

  • A.True
  • B.False
  • C.Depends on the compiler
  • D.depends on the standard

Answer: A

Correct answer: True

Both && and || short-circuit, and the standard requires it rather than leaving it to the compiler. If the left operand of && is false, or of || is true, the result is already determined and the right operand is not evaluated at all - side effects in it simply do not happen.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.