Relational Operators in C Programming

Relational Operators in C programming are used to compare two values. It specifies the relation between two values like equal, greater than, less than etc. Relational operators always returns boolean value (zero for false and non-zero value for true).

For Example
(A > B) : It checks whether A is greater than B or not. It will return none-zero(true) if A is greater than B otherwise zero(false).

Below is the list of Relational Operators Supported in C

Relational Operator Example Description
> A > B Checks if A is greater than B
< A < B Checks if A is less than B
>= A >= B Checks if A is greater than or equal to B
<= A <= B Checks if A is less than or equal to B
== A == B Checks if A is equal to B
!= A != B Checks if A is not equal to B

C Program to compare two numbers using Relational Operators

Relational Operators in C Programming

#include<stdio.h>
#include<conio.h>
 
int main(){
 
    int A = 10, B = 5;
 
    if(A>B){
        printf("A is greater than B\n");
    } else {
        printf("A is less than B\n");
    }
     
    if(A == B){
        printf("A is equal to B\n");
    } else {
        printf("A is not equal to B\n");
    }
     
    getch();
    return(0);
}

Output

A is greater than B
A is not equal to B