Relational Operators

Relational Operators are used to states the truth value of the expression. Result of these operators are either 1 (for true) or 0 (for false). There are six such operators in C language.

< (less than), > (greater than), <= (less than or equal to), >= (greater than or equal to)
==(equal to), != (not equal to)






Four operators (<, >, <=, >=) have higher priority than the two operators(==, !=).

Example

int main()
{
int x;
x=5<3; printf(“%d”,x); return(0); }

Output is:
0

Explanation:

As the relation 5<3 is false, x will contain 0 as a result of operation. Example int main()
{
int x;
x=5>4>3;
printf(“%d”,x);
return(0);
}

Output is:
0

Explanation:

5>4 results 1. so the expression becomes x=1>3 which is false, thus the result is 0.

If you want to learn more on relational operators watch this.

Relational Operators