Can someone explain how to use logical operators? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can someone explain how to use logical operators?

14th Feb 2017, 4:46 AM
raiyan
raiyan - avatar
2 Answers
0
! — NOT — inverts its operand. && — AND — returns true only if both operands are true. || — OR — returns true if at least one of operands is true.
14th Feb 2017, 5:03 AM
DotJason
0
You can use logical operators in conditional statements such as if statement like if(a==0 && b==0) -> condition will be true only if both are zero if(a==0 || b==0) -> condition will be true only if any one of them is zero if(!(a==0 && b==0)) -> it will negate the output of the condition.
14th Feb 2017, 5:15 AM
Varun Moghe
Varun Moghe - avatar