How to use relational operators in c language

program to use relational operators in c language


#include<stdio.h>
int main()
{
    int x,y;
    printf("Enter values for x and y : ");
    scanf("%d%d",&x,&y);
    if(x<y)
    printf("%d is less than %d\n",x,y);
    if(x<=y)
    printf("%d is less than or equal to %d\n",x,y);
    if(x==y)
    printf("%d is equal to %d\n",x,y);
    if(x!=y)
    printf("%d is not equal to %d\n",x,y);
    if(x>y)
    printf("%d is greater than %d\n",x,y);
    if(x>=y)
    printf("%d is greater than or equal to %d\n",x,y);
    return 0;
}

output


Enter values for a and b : 25
20
25 is not equal to 20
25 is greater than or equal to 20

Steps Description

  1. Declare integer variable x and y
  2. printf inbuild function to display value of variable x and y with respective decimal placeholder %d
  3. Evaluation of variable x and variable y to determine if a is less than b
  4. printf inbuild function to display value of variable x and y only when value of x is less than value of y
  5. Evaluation of variable x and variable y to determine if x is less than equal y
  6. printf inbuild function to display value of variable x and y only when of x is less than or equal to
  7. Evaluation of variable x and variable y to determine if x is equal y not
  8. printf inbuild function to display value of variable x and variable y only when of x is equal to y
  9. Evaluation of variable x and variable y to determine if not equal
  10. printf inbuild function to display value of variable x and variable y only when value of x is not equal to
  11. Evaluation of variable x and variable y to determine if greater than y
  12. printf inbuild function to display value of x is greater than y only when value of y is
  13. Evaluation of variable x and variable y to determine if x greater than or equal to
  14. printf inbuild function to display value of x only when value of x is greater than or equal to