Correct option is C
In the original code, the condition is n1 > n2, so if n1 is greater, it gets printed; otherwise, n2 is printed — effectively printing the larger value.
When the condition is changed to n1 < n2, it reverses the logic — now if n1 is less than n2, then n1 will be printed; otherwise, n2 will be printed. This results in always printing the smaller of the two numbers.
Important Key Points:
- Changing the condition from > to < switches the focus from maximum to minimum.
- Both branches (if and else) print one of the two inputs, ensuring one output in all cases.
- Logical comparison operators like < or > dictate which value is chosen based on relative magnitude.
Knowledge Booster:
- n1 will be displayed: Not always true — it depends on the comparison. If n2 < n1, then n2 will be printed.
- Largest of the two numbers will be displayed: This is true only when using n1 > n2, not when using n1 < n2.
- n2 will be displayed: Again, only true if n1 is not less than n2; not guaranteed.