Answer & Solution
Answer: Option
D
Solution:
In C, the logical OR operator (||) behaves as follows:
If the first operand evaluates to true, the entire expression is considered true, and further evaluation is stopped.
If the first operand evaluates to false, the evaluation continues with the second operand. If the second operand evaluates to true, the entire expression is considered true.
If both operands evaluate to false, the entire expression is considered false.
Based on this behavior, the evaluation doesn't stop when one of its components evaluates to true (contrary to option II). Instead, it stops when one of its components evaluates to false.
Regarding option IV, the evaluation of the logical OR operator (||) is left-to-right, so option IV is correct.
So, the correct answer is indeed Option D: II and IV, which means the evaluation will stop when one of its components evaluates to false, and the evaluation takes place from left to right. Thank you for pointing out the correction.