Answers for "a relational operator in c"

C
0

Relational Operators in c

// Working of relational operators
#include <stdio.h>
int main()
{
    int a = 5, b = 5, c = 10;

    printf("%d == %d is %d \n", a, b, a == b);
    printf("%d == %d is %d \n", a, c, a == c);
    printf("%d > %d is %d \n", a, b, a > b);
    printf("%d > %d is %d \n", a, c, a > c);
    printf("%d < %d is %d \n", a, b, a < b);
    printf("%d < %d is %d \n", a, c, a < c);
    printf("%d != %d is %d \n", a, b, a != b);
    printf("%d != %d is %d \n", a, c, a != c);
    printf("%d >= %d is %d \n", a, b, a >= b);
    printf("%d >= %d is %d \n", a, c, a >= c);
    printf("%d <= %d is %d \n", a, b, a <= b);
    printf("%d <= %d is %d \n", a, c, a <= c);
  
//Output

//5 == 5 is 1
//5 == 10 is 0
//5 > 5 is 0
//5 > 10 is 0
//5 < 5 is 0
//5 < 10 is 1
//5 != 5 is 0
//5 != 10 is 1
//5 >= 5 is 1
//5 >= 10 is 0
//5 <= 5 is 1
//5 <= 10 is 1 
    return 0;
}
Posted by: Guest on March-01-2022
0

Relational Operator in C language

#include<stdio.h>
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”);
}

}
Posted by: Guest on January-08-2022

Code answers related to "C"

Browse Popular Code Answers by Language