The Relational operators are :

Assume that the variable X holds 10 and variable Y holds 20 :

Operator | Descriptions | Example |
---|---|---|

== | Checks if the values of two operands are equal or not, if true then condition becomes true. | (X == Y) is not true. |

!= | Checks if the values of two operands are equal or not, if values are not equal then condition becomes true. | (X != Y) is true |

> | Checks if the value of left operand is greater than the value of right operand, if yes then condition becomes true. | (X > Y) is not true. |

< | (X < Y) is true. | |

>= | Checks if the value of left operand is greater than or equal to the value of right operand, if yes then condition becomes true. | (X >= Y) is not true. |

<= | Checks if the value of left operand is less than or equal to the value of right operand, if yes then condition becomes true. | (X <= Y) is true.. |

#include <stdio.h> void main() { { int x = 21; int y = 10; if( x == y ) { printf("Line 1 - x is equal to b\n" ); } else { printf("Line 1 - x is not equal to y\n" ); } if ( x < y ) { printf("Line 2 - x is less than y\n" ); } else { printf("Line 2 - x is not less than y\n" ); } if ( x > y ) { printf("Line 3 - x is greater than y\n" ); } else { printf("Line 3 - x is not greater than y\n" ); } // Lets change value of x and y x = 5; y = 20; if ( x <= y ) { printf("Line 4 - x is either less than or equal to y\n" ); } if ( x >= y ) { printf("Line 5 - y is either greater than or equal to y\n" ); } getch(); }

Line 1 - x is not equal to y

Line 2 - x is not less than y

Line 3 - x is greater than y

Line 4 - x is either less than or equal to y

Line 5 - y is either greater than or equal to y