Relational Operators in C

C language provides six relational operators which include the greater than (>), greater or equal (>=), lesser than (<), lesser or equal (<=), equal (==), and not equal (!=) operator. These operators are used to compare two numeric values and thus are binary operators. All these operators perform the function what is signified by their name. Operands can be constants or variables containing integer quantities, floating-point quantities or characters. In addition, the operands can be arithmetic expressions. A relational operator along with its operand(s) gives rise to Relational Expression. It is worth mentioning here that the equality operator is “==” and not “=”, which is an assignment operator. The output of a relational expression is a Boolean value (true=non-zero or false=0) decided by the nature of operation. Table 1 enumerates the working of each relational operator.

Screenshot from 2020-07-14 06-53-03

Table 1: Usage and meaning of Relational operators

Program 1 shows these operators in action which is followed by the screenshot of the output.

#include <stdio.h>
void main()
int i, j, k;
i = 10;
j = 20;
k = i < j;
printf(“i < j is %d\n”,k);
k = i <= j;
printf(“i <= j is %d\n”,k);
k = i == j;
printf(“i == j is %d\n”,k);
k = i != j;
printf(“i != j is %d\n”,k);
k = i > j;
printf(“i > j is %d\n”,k);
k = i >= j;
printf(“i >= j is %d\n”,k);


Program 1: Program shows binary relational operators in action