Logical Operators

Logical operators are used for logical operations. These Operations are used for compound relational expressions. When more than one relational expression occur in a C programming Language using logical operators, then such type of expressions are called Compound Relational expressions. These are used in decision making statement and some looping statements like if, switch, do while, and for statements etc. Following are the logical operators used in the C programming language –

Operator Meaning
! Logical NOT
|| Logical OR
&& Logical AND

For ex: if a,b and c are the three numbers, then the biggest number can be find by using below logical expression having logical AND operator

if(a>b && a>c)
     printf(" A is the greatest number ");

If both the conditions are true, then the action will be taken (i.e ‘ if ‘ block will be processed). Likewise you can also use the other two relational operators in the C programming language.

yashan has written 69 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>