The relational operator in C are mostly used for comparison purpose of two values of two expressions. Those expressions which use relational operators are also known as relational expressions.

## Following are the relational operator in C :

- The relation operators are mostly used in looping and control statements (if…..else) .The relations operators >,<,<=,>= have the same precedence. The operator == and != have just low precedence then above mentioned operators.
- Relational operators have low precedence as comparison to arithmetic operators. So while using these operators in any expression or inside looping precedence must be taken care of.
- Logical operators in C results in numeric value of 1 and 0 for its expression for true and false respectively (every non zero values are considered to be true in C whereas 0 is considered as false) .

The code given below will clear you more about relational operator:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
/*This program takes two integer number as input from user and shows result related to relational operator.*/ #include<stdio.h> int main() { int num1,num2;//integer variables printf("enter two integer values:\n"); scanf("%d %d",&num1,&num2);//taking input if(num1>num2)//comparison using greater than operator printf("%d is greater than %d:\n",num1,num2); if(num1<num2)//comparison using less than operator printf("%d is less than %d :\n",num1,num2); if(num1<=num2)//comparison using less than equal to operator printf("%d is less than or equal to %d\n",num1,num2); if(num1>=num2)//comparison using greater than equal to operator printf("%d is greater than or equal to %d\n",num1,num2); if(num1==num2)//comparison using equal to operator printf("%d and %d are equal:\n"); if(num1!=num2)//comparison using not equal to operator printf("%d is not equal to %d:\n"); return 0; } |

Program compiled in Code::Blocks compiler.

================================================================================

**OUTPUT:**

================================================================================

1 2 3 4 5 |
enter two integer values: 20 13 20 is greater than 13: 20 is greater than or equal to 13 20 is not equal to 13: |

**Output on program for two different numbers**

1 2 3 4 5 |
enter two integer values: 10 20 10 is less than 20 : 10 is less than or equal to 20 10 is not equal to 20: |

**Output of program for two same numbers**

1 2 3 4 5 |
enter two integer values: 10 10 10 is less than or equal to 10 10 is greater than or equal to 10 10 and 10 are equal: |

Operators are most important topics for asking questions in IT Quiz Competition.

To check your command in Operators visit Online Test powered by Quick Solution.

### Click here to go program gallery of Quick Solution.