RELATIONAL OPERATORS IN C

Maha




Relational Operators In C

In C programming, relational operators are used to comparing two values and return a result is called comparison. There are some common relational operators in C:

Relational Operators Are:

==   equal to

!=    not equal to

>     greater than

<     less than

>=   greater than or equal to

<=   less than or equal to


Example For Equality Comparison:

Program:


  #include<stdio.h>
  int main() {
    int a,b;
    a=10;
    b=5;
    printf("%d",a==b);
  }


Output:

  
  0


Example For Inequality Comparison:

Program:


  #include<stdio.h>
  int main() {
    int a,b;
    a=10;
    b=5;
    printf("%d",a!=b);
  }


Output:

  
  1


Example For Greater Than Comparison:

Program:

  
  #include<stdio.h>
  int main() {
    int a,b;
    a=10;
    b=5;
    printf("%d",a>b);
  }


Output:

 
  1


Example For Less Than Comparison:

Program:


  #include<stdio.h>
  int main() {
    int a,b;
    a=10;
    b=5;
    printf("%d",a<b);
  }


Output:



  0


Example For Greater Than Or Equal To Comparison:

Program:


  #include<stdio.h>
  int main() {
    int a,b;
    a=10;
    b=5;
    printf("%d",a>=b);
  }


Output:


  1



Example For Less Than Or Equal To Comparison:

Program:

  
  #include<stdio.h>
  int main() {
    int a,b;
    a=10;
    b=5;
    printf("%d",a<=b);
  }


Output:

 
  0





More topic in C


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send