Q1.Marks: +2.0UGC NET Paper 2: Computer Sc 6th Jan 2025 Shift 1
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.D, B, A, C
2.B, D, C, A
3.B, D, A, C✓ Correct
4.A, B, D, C
Solution
The correct answer is Option 3.
Key Points
To determine the order of execution of the operations in the given conditional statement if (m == 20 - 10 || n > 10), we need to consider the operator precedence in C-like programming languages.
Operator precedence determines the order in which parts of an expression are evaluated.
Here is the precedence of the operators involved, from highest to lowest:
Subtraction (-)
Relational equality (==)
Relational greater than (>)
Logical OR (||)
Additional Information
According to the operator precedence:
First, the subtraction operation (B) is performed: 20 - 10.
Then, the equality operation (A) is evaluated: m == 10.
Next, the relational greater than operation (D) is evaluated: n > 10.
Finally, the logical OR operation (C) is performed to combine the two relational results.