How to use relational operators in c language
Relational Operators
On this page
Relational Operators
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
- Declare integer variable x and y
- printf inbuild function to display value of variable x and y with respective decimal placeholder %d
- Evaluation of variable x and variable y to determine if a is less than b
- printf inbuild function to display value of variable x and y only when value of x is less than value of y
- Evaluation of variable x and variable y to determine if x is less than equal y
- printf inbuild function to display value of variable x and y only when of x is less than or equal to
- Evaluation of variable x and variable y to determine if x is equal y not
- printf inbuild function to display value of variable x and variable y only when of x is equal to y
- Evaluation of variable x and variable y to determine if not equal
- printf inbuild function to display value of variable x and variable y only when value of x is not equal to
- Evaluation of variable x and variable y to determine if greater than y
- printf inbuild function to display value of x is greater than y only when value of y is
- Evaluation of variable x and variable y to determine if x greater than or equal to
- printf inbuild function to display value of x only when value of x is greater than or equal to