C language has three different logical operators namely &&(AND) ; ||(OR) and !(NOT).
The AND and OR operator allows two or more conditions to be combined in an if statements.
The NOT operator reverses the result of the expression it operates on.
That is,if the expression evaluates to non-zero value,then applying !(NOT operator) results in 0.Similarly,if the expression evaluates to 0 then on applying ! operator to it makes it 1,a non zero value.
Operators Hierarchy:
Operators |
Type |
! |
Logical NOT |
* / % |
Arithmatic |
+ - |
Arithmatic and modulus |
< > <= >= |
Relational |
== != |
Relational |
&& |
Logical AND |
|| |
Logical OR |
= |
Assignment |