Relational Operators

Relational Operators are used to determine relationship between two operands. The output of the operation performed by relation operators on the operand is either 0 or 1. The different types of relational operators are as follow:

i. is equal to == operator :

Checks whether the operands on either sides are equal or not and returns 1 if equal else returns 0. For Example:

Consider A = 20 and B = 10
A==B would results 0 

ii. is not equal to != operator :

Checks whether the operands on either sides are equal or not and returns 1 if not equal else returns 0. For Example:

Consider A = 20 and B = 10
A!=B would results 0 

iii. is greater than > operator :

Checks whether the operand on left side is greater than operand on right side and returns 1 if true. For Example:

Consider A = 20 and B = 10
A>B would results 1 

iii. is less than < operator :

Checks whether the operand on left side is less than operand on right side and returns 1 if true. For Example:

Consider A = 20 and B = 10
A<B would results 0 

iii. is less than or equal to <= operator :

Checks whether the operand on left side is less or equal to the operand on right side and returns 1 if true. For Example:

Consider A = 20 and B = 10
A<=B would results 0 

iii. is greater than or equal to >= operator :

Checks whether the operand on left side is greater or equal to the operand on right side and returns 1 if true. For Example:

Consider A = 20 and B = 10
A>=B would results 1 

Program example of relational operators

//An example of relational operators
#include<stdio.h>

int main()
{
  int A= 20, B=10;
  printf("Consider A = %d and B = %d \n",A,B);
  printf("is equal to operator (A==B) = %d \n",A==B);
  printf("is not equal to operator (A!=B) = %d \n",A!=B);
  printf("is greater than operator (A>B) = %d \n",A>B);
  printf("is less than operator (A<B) = %d \n",A<B);
  printf("is less than or equal to operator (A<=B) = %d \n",A<=B);
  printf("is greater than or equal to operator (A>=B) = %d \n",A>=B);
  return 0;
}

Output

Consider A = 20 and B = 10
is equal to operator (A==B) = 0
is not equal to operator (A!=B) = 1
is greater than operator (A>B) = 1
is less than operator (A<B) = 0
is less than or equal to operator (A<=B) = 0
is greater than or equal to operator (A>=B) = 1