Relational Operators in C Language
RELATIONAL OPERATORS
A relational operator checks the relationship between two operands. If the relation is true, it returns 1; if the relation is false, it returns value 0.
Here, in above top 3 has more priority than bottom 2 and if top 2 or bottom 2 come in same instruction/line then it's solve according to associative rule i.e left to right for example in program <,><=,>= is written then you should start solving it from left i.e first solve < then > and so on .
Rules--
Example :1
#include <stdio.h>
int main()
{
int a=5, b=5, c=10;
printf("%d = = %d =%d \n", a, b, a= = b); // true
printf("%d = = %d =%d \n", a, c, a= = c); // false
printf("%d > %d =%d \n", a, b, a> b); // false
printf("%d > %d =%d \n", a, c, a> c); // false
printf("%d < %d =%d \n", a, b, a < b); // false
printf("%d < %d =%d \n", a, c, a < c); // true
printf("%d != %d =%d \n", a, b, a! = b); // false
printf("%d ! = %d =%d \n", a, c, a! = c); // true
printf("%d > = %d =%d \n", a, b, a> = b); // true
printf("%d > = %d =%d \n", a, c, a> = c); // false
printf("%d < = %d =%d \n", a, b, a< = b); // true
printf("%d < = %d =%d \n", a, c, a< = c); // true
return 0;
}
Output
5 = = 5 = 1
5 = = 10 = 0
5 > 5 = 0
5 > 10 = 0
5 < 5 = 0
5 < 10= 1
5 ! = 5 = 0
5 ! = 10 = 1
5 > = 5 = 1
5 > = 10 = 0
5 < = 5 = 1
5 < = 10 = 1
Comments
Post a Comment