Logical Operators in C Language


Logical Operators

An expression containing logical operator returns either 0 or 1 depending upon whether expression results true or false.
logical operators in c,conditional operator in c

Here above 3 Logical Operator are arrange in according to it's priority order i.e           NOT>AND>OR .

NOT Logical Operator

logical operators in c,conditional operator in c



EXAMPLE  OF !


logical operators in c,conditional operator in c
Example of ! operator



OUTPUT :-  0



Note :- In the quotation given above, Output is zero because the ! is a unary operator so first of all, the !x has run and in place of !x the value come 0  then next expression i.e 0>4 is solve .





AND Logical Operator


logical operators in c,conditional operator in c
syntax of && operator




EXAMPLE  OF &&


logical operators in c,conditional operator in c
Example of && operator


OUTPUT :-  0


NOTE:--  Here in above example y=x>4&&x<10 , first of all x>4 is solve because it's                                    priority order higher then amongs all so in place of x>4 , 1 value is come                                        then && operator run and 1<10 is false=0 so according to table                                                         if either of two statement value is zero so output will be zero.





OR Logical Operator


logical operators in c,conditional operator in c
OR operator




EXAMPLE  of OR Operator



logical operators in c,conditional operator in c
Example of OR operator

OUTPUT :-  1 (because as per above table if eihter of two statement one                                              value is  true so output will be true (1).) 




Comments

Popular posts from this blog

Notepad, Wordpad and Paint

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN

O LEVEL- INTERNET TECHNOLOGY & WEB DESIGN