The relational operators in C are used for the comparison of the two operands. All these operators are binary operators that return true or false values as the result of comparison.

Symbol

Operator

Description

Syntax

< 

Less than

Returns true if the left operand is less than the right operand. Else false 

a < b

> 

Greater than

Returns true if the left operand is greater than the right operand. Else false 

a > b

<=

Less than or equal to

Returns true if the left operand is less than or equal to the right operand. Else false 

a <= b

>=

Greater than or equal to

Returns true if the left operand is greater than or equal to right operand. Else false 

a >= b

==

Equal to

Returns true if both the operands are equal.

a == b

!=

Not equal to

Returns true if both the operands are NOT equal.

a != b


SIMPLE C PROGRAMMING USING RELATIONAL OPERATORS

// C program to illustrate the relational operators

#include <stdio.h>

int main()

{

            int a = 25, b = 5;

            // using operators and printing results

            printf("a < b : %d\n", a < b);

            printf("a > b : %d\n", a > b);

            printf("a <= b: %d\n", a <= b);

            printf("a >= b: %d\n", a >= b);

            printf("a == b: %d\n", a == b);

            printf("a != b : %d\n", a != b);

            return 0;

        Output

                a < b  : 0

                a > b  : 1

                a <= b: 0

                a >= b: 1

                a == b: 0

                a != b : 1

Here, 0 means false and 1 means true.