Relational Operators in C Language
This “Relational Operators in C Language” post giving information about available relational operators in c, associativity, Priority and Use of these operators using suitable examples.
- Relational operators compare two operands and determine the validity of a relationship.
- Returns 1, if the relation is true
- Returns 0, if the relation is false
- Operators are >, <, >= ,<= , == , !=
- To check the relation between two operands, first we must execute those two operands.
- for example…. a = ++b >= –c ;
- Here ++b & –c execute first and then we should evaluate the relation.
Greater than >
Less than <
Greater than or equals >=
Less than or equals <=
e = a++ != d–;
f = ++b == d++;
g = c– >= ++d;
h = ++d >= ++a;
Note : arithmetic operators having higher priority than relational operators.
int a=5 , b=2 , c=3, d, e;
d = a == b + c;
e = (a == b) – c;
Note : All the relational operators having equal priority (left -> right evaluation).
int a=35, b=15, c=25,d;
d = a > c > b;