Home

A program to explain relational operators

C Programming Language 013

The following code shows how to write a program to explain relational operators

Program

#include <stdio.h>

void main()
{
    int a, b, c;
    printf("Enter a, b values: ");
    scanf("%d %d", &a, &b);

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

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

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

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

    printf("\n");
}

Result

Enter a, b values: 5 8
(a >= b) : 0
(a <= b) : 1
(a == b) : 0
(a != b) : 1


Last Updated on

Next Post: Rules vs Guidelines →

Comments