Relational Operators are those operators, which are used to find the relation between two operands. In C we need to perform some operations to know the relation between the operands, such operators are listed under the relational operators. When we use such a operator, the result gives out to be either 1 or 0 i.e., true or false.
The below table gives a list of relational operators which we use in C.
The below table gives a list of relational operators which we use in C.
Operator
|
Symbol
|
Description
|
Examples
|
Equals
|
==
|
Does first value equal to second value
|
X==Y
|
Not Equals
|
!=
|
Does first value not equal to second value
|
X!=Y
|
Less than
|
<
|
Whether first value is less than second
|
X<Y
|
Less than or Equal to
|
<=
|
Whether first value is less than or equal to second value
|
X<=Y
|
Greater than
|
>
|
Whether first value is greater than second value
|
X>Y
|
Greater than or Equal to
|
>=
|
Whether first value is greater than or equal to second value
|
X>=Y
|
Based on the above table, we use the relations to make a condition to solve a problem in C.
All the above operators result in 1 if the condition is true, otherwise they return 0 i.e., false.
Examples:
3==5 returns 0( false)
3<5 returns 1 (True)
5<5 returns 0 (False)
5<=5 returns 1 (True)Thus we can use relational operators in conditions to solve problems in C.