Consider following conditional statements if (m == 20 – 10 || n > 10). The…
2025
Consider following conditional statements if (m == 20 – 10 || n > 10). The order of execution of the following operations is
A. ==
B. –
C. ||
D. >
Choose the correct answer from the options given below:
- A.
D, B, A, C
- B.
B, D, C, A
- C.
B, D, A, C
- D.
A, B, D, C
Attempted by 684 students.
Show answer & explanation
Correct answer: C
Key idea: operator precedence determines the order of evaluation. Arithmetic operators are evaluated before relational operators, relational operators before equality, and logical OR is evaluated last.
Precedence summary: - (subtraction) > relational (> , < , >= , <=) > equality (== , !=) > logical OR (||).
Apply this to the expression m == 20 - 10 || n > 10:
Step 1: Evaluate the subtraction 20 - 10.
Step 2: Evaluate the relational comparison n > 10 (relational operators have higher precedence than equality).
Step 3: Evaluate the equality comparison m == (result of 20 - 10).
Step 4: Apply the logical OR (||) to combine the two comparison results. At runtime, || may short-circuit and skip evaluating the right-hand side if the left-hand side is true.
Therefore, the order of execution is: subtraction (-), greater-than (>), equality (==), logical OR (||).
A video solution is available for this question — log in and enroll to watch it.