Logical operators are use to combine two or more than two condition. Mean it use when we have more than one checks for a single condition.
We have the following three different logical operators.
We have the following three different logical operators.
1) && ( and operator).
And operator is use to combine more than one condition and return true or false that depends on the given condition.
If will return true if all given conditions are true and it will return false if any single condition is false. And operator is denoted by double ampersand symbol. ( & &).
For example:
1) if ( a> 50 && b<100)
2) if ( a> 50&& b<100 && c= =20)
2) || ( or operator).
Or operator is use to combine more than one condition and return true or false that depends on the given condition.
It will return true if any single condition is true and it will return false if all conditions are false. Or operator is denoted by double symbol. ( ||)
For example:
1) if( a>50&&b<100)
2) if ( a>50|| b<100|| c= =20)
3) if( a>50 || b<100&&c= =)
3) ! ( not operator)
Not operator is denoted by sign (!).
for example:
if ( a! =40&&b!<90|| d!>100)etc.
Relational operators:
< less than 1<5
> Greater than 50>30
<= less than equal to per>=40
>= Greater than equal to avg <= 90
== equal to M==40
!= not equal to N! = farid