The relational operators allows to compare two or more values to see whether they are equal or unequal.

Relational operator

  Operator   Meaning
< Is less than
<= Is less than or equal to
> Is greater than
>=   Is greater than or equal to  
!= Is not equal to
== Is equal to

Consider the statement
  Expression     Interpretation     Value  
a<b True 1
b>c False 0
a<=b True 1
c>=b True 1
c!=3 False 0
a==1 True 1

Codings for the above Example:
  int main()
  int a=1,b=2,c=3;
  {printf("a is less then b  ,value= 1 \n");}
  else{printf("a is not less then b  ,value=0 \n");}
  {printf("b is greater then c  ,value=1 \n");}
  else{printf("b is not greater then c  ,value=0 \n");}
  {printf("a is less then or equal to b  ,value=1 \n");}
  else{printf("a is not less then or equal to b  ,value=0 \n");}
  {printf("c is greater then or equal to b  ,value=1 \n");}
  else{printf("c is not greater then or equal to b  ,value=0 \n");}
  {printf("c is not equal to 3  ,value=1 \n");}
  else{printf("c is equal to 3  ,value=0 \n");}
  {printf("a is equal to 1  ,value=1 \n");}
  else{printf("a is not equal to 1  ,value=0 \n");}
  return 0;

Run Example >

< Previous Next >

Privacy Policy Terms of Service About
Creative Commons License
This work is licensed under a Creative Commons Attribution-NoDerivatives 4.0 International License.