Skip to content

Logical Operators

by yashan on August 10th, 2011

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.

From → C Tutorials

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS