Table of Contents
show
Relational operators are used to compare two operands.
- The result of evaluation of a relational expression is a boolean constant i.e. 0 or 1
- The result of the relation expression is 1 if the specified condition is true else it is 0
- An expression that includes relation operator is termed as condition
There are six relational operators,
Example
Illustration of Relational operator
#include<stdio.h>
int main()
{
int a;
a = 2 < 3 != 2;
printf("a=%d",a);
return 0;
}
Output
a=1
Explanation
All the relational operators are having left to right associativity. Thus 2<3 is evaluated first and it returns 1 as it is true. Then 1 != 2 is done which is true, so the result is 1
Views: 0