Relational Operators in C

Relational Operators in C

Relational operators in C are used to check the relation between two operands. 0 and 1 are the results given by relational operators. If the relationship comes out to be true, it returns 1. If the relationship is false, it returns 0.

The list of relational operators is given below:

Operator Description
== Equal to: To check whether two operands are equal or not.
!= Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to



Let’s understand all operators through a program.


int main()


            int a=8;

            int b=3;









Relational Operators in C


Equality operator returns 0 since 8==3 is false.

Not equal to operator returns 1 since 8!=3 is true.

Greater than operator returns 1 since 8>3 is true.

Less than operator returns 0 since 8<3 is false.

Greater than or equal to operator returns 1 since 8>=3 is true.

Less than or equal to operator returns 0 since 8<=3 is false.

Note: If either of the relations in ‘>=’ and ‘<=’ is true, the result will be 1. In ‘8>=3’, 8 is greater than 3, but 8 equals 3 is false. However, the overall output is true. In ‘8<=3’, both relations are false. Hence, the output is 0.

Difference Between ‘=’ and ‘==’

Most of the users always have confusion in ‘=’ and ‘==’ operators. However, both look the same but work differently in our programming languages.

=’ is the assignment operator that assigns a value to a variable.

==’ is the equality operator that compares the equality of two operands.

For example,


The above statement means we are assigning ‘5’ in the variable ‘Y’. Always remember that assignment is done from right to left.

Difference Between ‘=’ and ‘==’


Here, we compare whether ‘5’ is equal to ‘Y’ or not.


  • Barry Allen

    A Full Stack Developer with 10+ years of experience in different domain including SAP, Blockchain, AI and Web Development.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.