Relational Operators
Often it is required to compare the
relationship between operands and bring out a decision and program accordingly.
These comparisons can be done with the help of operators known as “relational
operators”. An expression containing relational operator is known as
“relational expression”.
Operator
|
Meaning
|
Operator
|
Meaning
|
<
|
is less than
|
>=
|
is greater than or equal to
|
<=
|
is less than or equal to
|
==
|
is equal to
|
>
|
is greater than
|
!=
|
is not equal to
|
A simple relational expression contains only one
relational operator and takes the following form.
exp1 relational-operator exp2
Where exp1 and exp2 are expressions, which may be simple
constants, variables or combination of them.
Relation Expression returns non-zero value if
the condition is TRUE otherwise returns zero when the condition is false.
6.7<=10 TRUE
7.5<-10 FALSE
7.5<-10 FALSE
-42>=0 FALSE
10<9+4 TRUE
a+b==c+d TRUE only if sum of a & b and sum of c & d are equal otherwise FALSE.
a+b==c+d TRUE only if sum of a & b and sum of c & d are equal otherwise FALSE.
Relational expressions are used in decision making statements of C
language such as if,
while and for statements to decide the course of
action of a running program.
No comments:
Post a Comment