![]() |
VOOZH | about |
In C, relational operators are the symbols that are used for comparison between two values to understand the type of relationship a pair of numbers shares. The result that we get after the relational operation is a boolean value, that tells whether the comparison is true or false. Relational operators are mainly used in conditional statements and loops to check the conditions in C programming.
There are a total of 6 relational operators in C language. There are:
The C equal to operator (==) is a relational operator that is used to check whether the two given operands are equal or not.
Syntax
operand1 == operand2
For example, 5==5 will return true.
The C not equal (==) to operator is another relational operator used for checking whether the two given operands are equal or not.
Syntax
operand1 != operand2
For example, 5!=5 will return false.
The greater than operator is a relational operator in C that checks whether the first operand is greater than the second operand or not.
Syntax
operand1 > operand2
For example, 6>5 will return true.
The less than operator is a relational operator in C that checks whether the first operand is lesser than the second operand.
Syntax
operand1 < operand2
For example, 6<5 will return false.
Note: The greater than and less than operator are not equal to the complement of each other.
The greater than or equal to the operator is a relational operator in C that checks whether the first operand is greater than or equal to the second operand.
Syntax
operand1 >= operand2
For example, 5>=5 will return true.
The less than or equal to the operator is a relational operator in C that checks whether the first operand is less than or equal to the second operand.
Syntax
operand1 <= operand2For example, 5<=5 will also return true.
a is greater than b a is greater than or equal to b a is greater than or equal to b a is greater than b a and b are not equal a is not equal to b