Relational Operator in C language 1

Relational Operator in C language

#include
int main(){

int a = 20;
int b = 10;
int c;

// == operator
if(a == b){
 printf(“a is equal to b\n”);
}else{
 printf(“a is not equal to b\n”);
}

// > operator
if(a > b){
 printf(“a is greater than b\n”);
}else{
 printf(“a is not greater than b\n”);
}

// < operator
if(a < b){
 printf(“a is less than b\n”);
}else{
 printf(“a is not less than b\n”);
}

// != Opertor
if(a != b){
 printf(“a is not equal to b\n”);
}else{
 printf(“a is equal to b\n”);
}

// >= orperator
if(a >= b){
 printf(“a is greater than or equal to b\n”);
}else{
 printf(“a is not greater than or equal to b\n”);
}

// <= operator
if(a <= b){
 printf(“a is less than or equal to b\n”);
}else{
 printf(“a is not less than or equal to b\n”);
}

}

Here is what the above code is Doing:
1. We are declaring two variables a and b and assigning values to them.
2. We are using the == operator to check if a is equal to b.
3. We are using the > operator to check if a is greater than b.
4. We are using the < operator to check if a is less than b. 5. We are using the != operator to check if a is not equal to b. 6. We are using the >= operator to check if a is greater than or equal to b.
7. We are using the <= operator to check if a is less than or equal to b.

Similar Posts