Relational Operators

Relational operators are used to compare expressions.

Relational operator checks the relationship between two operands or variables.

If the relation is true, it returns 1 and if the relation is false, it returns 0.

The relational operators are :

< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
== Equal to
!= Not equal to

Relational operations program

        
#include <stdio.h>

int main()
{
    int a = 20, b = 10;

    if(a < b)
    {
        printf("True\n");
    }
    else
    {
        printf("False\n");
    }

    if(a > b)
    {
        printf("True\n");
    }
    else
    {
        printf("False\n");
    }

    if(a <= b)
    {
        printf("True\n");
    }
    else
    {
        printf("False\n");
    }

    if(a >= b)
    {
        printf("True\n");
    }
    else
    {
        printf("False\n");
    }

    if(a == b)
    {
        printf("True\n");
    }
    else
    {
        printf("False\n");
    }

    if(a != b)
    {
        printf("True\n");
    }
    else
    {
        printf("False\n");
    }

    return 0;
}
        
    

Output

        
False
True
False
True
False
True
        
    

Post a Comment

0 Comments