Relational Operators in C

The relational operator is used to compare two values,for example compare two items price.thse comparisons can be done with the help of relational operators.the following list and explain the all relational operator in to details.

Sr.No

Options

Descriptions

01

<

Is less than

02

<=

Is less than or equal to

03

>

Is greater than

04

>=

Is greater than or equal to

05

==

Is equal to

06

!=

Is not equal to

Is less than (<)

This operator is used to compare value is less than or not,the following syntax and example.

Syntax


value1 < value2							
							

Example


10 < 20							
							

Is less than or equal to (<=)

This operator is used to compare value is less than or eqal to,the following syntax and example.

Syntax


value1 <= value2							
							

Example


10 <= 10							
							

Is greater than (>)

This operator is used to compare value is greater than or not,the following syntax and example.

Syntax


value1 > value2							
							

Example


10 > 20							
							

Is greater than or equal to (>=)

This operator is used to compare value is greater than or equal to,the following syntax and example.

Syntax


value1 >= value2							
							

Example


10 >= 20							
							

Is equal to (==)

This operator is used to compare value is equal or not,the following syntax and example.

Syntax


value1 == value2							
							

Example


10 == 10							
							

Is not equal to (!=)

This operator is used to check value Is not equal,the following syntax and example.

Syntax


value1 != value2							
							

Example


10 != 20							
							

Example of Relational Operators


#include 
 
int main()
{
   int a=20,b=10;
   if (a == b)
   {
       printf("A and B are Equal");
   }
   else
   {
       printf("A and B are Not Equal");
   }
}

Output


A and B are Not Equal
Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!