C Programming Language


Operator


Relational Operator :

The Relational operators are :
Assume that the variable X holds 10 and variable Y holds 20 :

Operator Descriptions Example
== Checks if the values of two operands are equal or not, if true then condition becomes true. (X == Y) is not true.
!= Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. (X != Y) is true
> Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. (X > Y) is not true.
< (X < Y) is true.
>= Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. (X >= Y) is not true.
<= Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. (X <= Y) is true..

Example :

Output :

Line 1 - x is not equal to y
Line 2 - x is not less than y
Line 3 - x is greater than y
Line 4 - x is either less than or equal to y
Line 5 - y is either greater than or equal to y