Search Placementyogi.com
 

Logical Operators in C

Like logic gates AND, OR and NOT whose output is 1 or 0, we have logical operators in C. After evaluation, expression consisting of logical operators results in either true or false and hence such expression are called logical expression.

Below table shows the logical operators in C.

Operator Description  Example
 ! It is called Logical Not (unary operator). Used to negate the state of its operand. if operand is true(1), Not makes it false(0).  if x is TRUE  then !x is FALSE
 && It is called logical AND operator. If both the operands are true then it AND of both is TRUE else AND of both is false.

if A=TRUE, B=FALSE 

A && B is FALSE
A && A is TRUE
B && B is FALSE
 || It is called logical OR operator. If any one operand is true then OR of both is TRUE, if both operands are false then OR of both is false. 

if A=TRUE, B=FALSE 

A || B is TRUE
A || A is TRUE
B || B is FALSE

 

Banner to LogicGuns.com

Hide Page Information
Logical Operators in c