C

Relation Operators

The following table shows all relation operators supported by C.

Operator Description
== Check if two operand are equal
!= Check if two operand are not equal.
> Check if operand on the left is greater than operand on the right
< Check operand on the left is smaller than right operand
>= check left operand is greater than or equal to right operand
<= Check if operand on left is smaller than or equal to right operand

Example:

//Write a C Program Which use of Relation Operators.
#include<stdio.h>
#include<conio.h>
void main()
{
    int mark;
    clrscr();
    printf("Enter Mark: ");
    scanf("%d",&mark);


    if (mark==100)
        printf("Superb :-)");
    else if (mark>=60)
        printf("First Class");
    else if (mark>=35)
        printf("Second Class");
    else if (mark<35)
        printf("Fail");

    getch();
}

Output 1:

Command Prompt
Enter Mark: 100
Superb :-)

Output 2:

Command Prompt
Enter Mark: 75
First Class

Output 3:

Command Prompt
Enter Mark: 57
Second Class

Output 4:

Command Prompt
Enter Mark: 32
Fail



Subscribe us on Youtube

Share This Page on


Ask Question