# C - Relational Operators

### <<Previous Next >>

The relational operators are used to distinguishes between two values depending upon their relations. This operators provide relationship between two expressions. The relational operators always return the result as a boolean values(true or false). If the relation is true, then it returns value 1. Otherwise it returns zero for false relation.

Operator DescriptionExample Return value
<less than4<5 1
>greater than4>5 0
<=less than equal to4<=51
>=greater than equal to4>=50
==equal to 4==5 0
!=not equal to 4!=5 1

Following is an example C Program using Relational Operators.

```#include <stdio.h>
#include <conio.h>

int main()
{
int a=20;
int b=35;

if(a>b){
printf("The value of a is greater than b\n");
}
else{
printf("The value of a is not greater than b\n ");
}

if(a<b){
printf("The value of a is less than b \n ");
}
else{
printf("The value of a is not less than b \n ");
}
if(a<=b){
printf("The value of a is less than and equal to b \n ");
}
else{
printf("The value of a is not less than and not equal to b \n ");
}
if(a>=b){
printf("The value of a is greater than and equal to b \n ");
}
else{
printf("The value of a is not greater  than  and not equal to b \n ");
}
if(a==b){
printf("The value of a is equal to b \n ");
}
else{
printf("The value of a is not equal to b \n ");
}
if(a!=b){
printf("The condition is true \n ");
}
else{
printf("The condition is false \n ");
}

return(0);
}
```

Output:

```The value of a is not greater than b
The value of a is less than b
The value of a is less than and equal to b
The value of a is not greater than and equal to b
The value of a is not equal to b
The conditon is true
```

# C - Relational Operators

### <<Previous Next >>

The relational operators are used to distinguishes between two values depending upon their relations. This operators provide relationship between two expressions. The relational operators always return the result as a boolean values(true or false). If the relation is true, then it returns value 1. Otherwise it returns zero for false relation.

Operator DescriptionExample Return value
<less than4<5 1
>greater than4>5 0
<=less than equal to4<=51
>=greater than equal to4>=50
==equal to 4==5 0
!=not equal to 4!=5 1

Following is an example C Program using Relational Operators.

```#include <stdio.h>
#include <conio.h>

int main()
{
int a=20;
int b=35;

if(a>b){
printf("The value of a is greater than b\n");
}
else{
printf("The value of a is not greater than b\n ");
}

if(a<b){
printf("The value of a is less than b \n ");
}
else{
printf("The value of a is not less than b \n ");
}
if(a<=b){
printf("The value of a is less than and equal to b \n ");
}
else{
printf("The value of a is not less than and not equal to b \n ");
}
if(a>=b){
printf("The value of a is greater than and equal to b \n ");
}
else{
printf("The value of a is not greater  than  and not equal to b \n ");
}
if(a==b){
printf("The value of a is equal to b \n ");
}
else{
printf("The value of a is not equal to b \n ");
}
if(a!=b){
printf("The condition is true \n ");
}
else{
printf("The condition is false \n ");
}

return(0);
}
```

Output:

```The value of a is not greater than b
The value of a is less than b
The value of a is less than and equal to b
The value of a is not greater than and equal to b
The value of a is not equal to b
The conditon is true
```