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
andy
printf
inbuild function to display value of variablex
and y with respective decimal placeholder %d- Evaluation of variable
x
and variabley
to determineif a is less than b
printf
inbuild function to display value of variablex
andy
only when value ofx
is less than value of y
- Evaluation of variable
x
and variabley
to determineif x is less than equal y
printf
inbuild function to display value of variablex
andy
only when ofx is less than or equal to
- Evaluation of variable
x
and variabley
to determineif x is equal y not
printf
inbuild function to display value of variablex
and variabley
only when ofx is equal to y
- Evaluation of variable
x
and variabley
to determineif not equal
printf
inbuild function to display value of variablex
and variabley
only when value ofx is not equal to
- Evaluation of variable
x
and variabley
to determineif greater than y
printf
inbuild function to display value ofx
is greater thany
only when value ofy is
- Evaluation of variable
x
and variabley
to determineif x greater than or equal to
printf
inbuild function to display value ofx
only when value ofx is greater than or equal to