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:

  1. A.

    D, B, A, C

  2. B.

    B, D, C, A

  3. C.

    B, D, A, C

  4. 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:

  1. Step 1: Evaluate the subtraction 20 - 10.

  2. Step 2: Evaluate the relational comparison n > 10 (relational operators have higher precedence than equality).

  3. Step 3: Evaluate the equality comparison m == (result of 20 - 10).

  4. 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.

Explore the full course: Mppsc Assistant Professor