Operators in C
 Relational Operators
 Logical Operators
Relational Operators
Operator Description Example
==
Equal to
Determine whether the two operands have same value or not. If equal,
then condition is true.
(A==B) is 0
!=
Not equal to
Determine whether the two operands have same value or not. If not
equal then condition is true.
(A!=B) is 1
>
Greater than
Determine whether the left side operand has greater value than the right
side operand. If it is, then the condition is true.
(A>B) is 0
<
Less than
Determine whether the left side operand has less value than the right
side operand. If it is, then the condition is true.
(A<B) is 1
>=
Greater than or equal to
Determine whether the left side operand has value greater than or equal
to the right side operand. If it is, then the condition is true.
(A>=B) is 0
<=
Less than or equal to
Determine whether the left side operand has value less than or equal to
the right side operand. If it is, then the condition is true.
(A<=B) is 1
Relational operators check the relationship between two operands. If the relation is
true , it returns 1; if the relation is false, it returns value 0.
Here we consider two variables A=5 and B=10
Logical Operators
Logical operators are used to check the conditions these operators are used
in decision making statements.
Here we consider two variables A=5 and B=10
Operator Description Example
&&
Logical
AND
Logical AND operator used to check multiple
conditions. True only if all the conditions are true.
(A!=B) && (B==10) is 1
||
Logical OR
Logical OR operator used to check multiple
condition. True if either of the condition is true.
(A>10) || (A<B) is 1
!
Logical
NOT
Logical NOT operator reverses the logical state of
the operand. If condition is true then false or vice
versa.
!(A>B) is 1
THANK YOU

Relational and logical operators

  • 1.
    Operators in C Relational Operators  Logical Operators
  • 2.
    Relational Operators Operator DescriptionExample == Equal to Determine whether the two operands have same value or not. If equal, then condition is true. (A==B) is 0 != Not equal to Determine whether the two operands have same value or not. If not equal then condition is true. (A!=B) is 1 > Greater than Determine whether the left side operand has greater value than the right side operand. If it is, then the condition is true. (A>B) is 0 < Less than Determine whether the left side operand has less value than the right side operand. If it is, then the condition is true. (A<B) is 1 >= Greater than or equal to Determine whether the left side operand has value greater than or equal to the right side operand. If it is, then the condition is true. (A>=B) is 0 <= Less than or equal to Determine whether the left side operand has value less than or equal to the right side operand. If it is, then the condition is true. (A<=B) is 1 Relational operators check the relationship between two operands. If the relation is true , it returns 1; if the relation is false, it returns value 0. Here we consider two variables A=5 and B=10
  • 4.
    Logical Operators Logical operatorsare used to check the conditions these operators are used in decision making statements. Here we consider two variables A=5 and B=10 Operator Description Example && Logical AND Logical AND operator used to check multiple conditions. True only if all the conditions are true. (A!=B) && (B==10) is 1 || Logical OR Logical OR operator used to check multiple condition. True if either of the condition is true. (A>10) || (A<B) is 1 ! Logical NOT Logical NOT operator reverses the logical state of the operand. If condition is true then false or vice versa. !(A>B) is 1
  • 6.