Logical Operators
You are given two integers A and B, and a logical operator op.
The supported operators are:
- && — Logical AND
- || — Logical OR
For logical operations, 0 is treated as false and every non-zero integer is treated as true.
Input
The input contains two space-separated integers A and B, followed by the operator op.
Output
Print 1 if the logical operation evaluates to true. Otherwise, print 0.
Example 1:
Input:
1 0 &&
Output:
0
Explanation:
1 && 0 evaluates to false because one operand is zero.
Example 2:
Input:
0 8 ||
Output:
1
Explanation:
0 || 8 evaluates to true because one operand is non-zero.
Now Your Turn!
Pick the correct output for the given inputInput:
3 5 ||
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- -100 <= A, B <= 100
- op is either && or ||