C Language

May 21, 2023

How to use relation operator in C Language

Program to use relation operator in C Language


#include <stdio.h>
int main()
{
    int a, b;
    printf("enter value for a and b : ");
    scanf("%d%d", &a, &b);

    if (a < b)
    {
        printf("%d is less than %d\n", a, b);
    }
    if (a <= b)
    {
        printf("%d is less than or equal to %d\n", a, b);
    }
    if (a == b)
    {
        printf("%d is equal to %d\n", a, b);
    }
    if (a != b)
    {
        printf("%d is not equal to %d\n", a, b);
    }
    if (a > b)
    {
        printf("%d is greater than %d\n", a, b);
    }
    if (a >= b)
    {
        printf("%d is greater than or equal to %d\n", a, b);
    }
    return 0;
}

output


enter value for a and b :16
7
16 is not equal to 7
16 is greater than 7
16 is greater than or equal to 7

by : Nadeem Khan

Quick Summary:

Program to use relation operator in C Language copy #include <stdio.h> int main() { int a, b; printf(“enter value for a and b : “); scanf(“%d%d”, &a, &b); if (a < b) { printf("%d is less than %d\n", a, b); } if (a b) { printf("%d is greater than %d\n", a, b); } if (a […]