In this blog |
---|
Relational operator |
Relational operator
operator | meaning | example |
---|---|---|
> | greater than | a > b returns 1 if true otherwise 0 |
< | less than | a<b returns 1 if true otherwise 0 |
<= | less than or equal to | a<=b returns 1 if true otherwise 0 |
>= | greater than or equal to | a>= b returns 1 if true otherwise 0 |
== | equality check | a == b returns 1 if true otherwise 0 |
!= | not equal to | a != b returns 1 if true otherwise 0 |
program illustration of relational operator
#include <stdio.h>
int main()
{
int a=2,b=3;
printf("greater than , a > b=%d\n",a > b); //greater than
printf("less than, a < b=%d\n",a < b ); //less than
printf("less than or equal to, a <= b=%d\n",a <= b); //less than or equal to
printf("greater than or equal to, a >= b=%d\n",a >= b); //greater than or equal to
printf("equality check, a == b =%d\n",a == b); //equality check
printf("not equal to , a != b =%d\n",a != b); //not equal to
return 0;
}
output:
greater than , a>b=0
less than, a < b=1
less than or equal to, a <= b=1
greater than or equal to, a >= b=0
equality check, a == b =0
not equal to , a != b =1
No comments:
Post a Comment