ExamVeda
Login
Home
Operators and Expressions
?

In an expression involving || operator, evaluation
I.   Will be stopped if one of its components evaluates to false
II.  Will be stopped if one of its components evaluates to true
III. Takes place from right to left
IV.  Takes place from left to right

Answer & Solution
Correct Answer: Option D
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.
Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
Dinithi Sahanika
Dinithi Sahanika 5 years ago
What it means "takes left to right"
Pratik Shete
Pratik Shete 9 years ago
thanks wani!
Wani Parvaiz
Wani Parvaiz 9 years ago
Logical || Operator evaluates to true if any one of input is true, so it'll not stop on if any one input is true or false. And one more thing is that the expression is evaluated from left to right. So your option is not appropriate and its answer must be E part.