Technologies

C

C Languages Relational Operators
(adsbygoogle = window.adsbygoogle || []).push({});

**Example's : **

4.5 <= 10 true

4.5 < -10 false

-35 >= 0 false

10 < 7 + 5 true

(10+5) == (3*5) true
# Relational Operator Complements :

(adsbygoogle = window.adsbygoogle || []).push({});
(adsbygoogle = window.adsbygoogle || []).push({});

CLanguage

Friday, 31 Mar 2017

275

0

0

**Relational Operators : ** Relational operators are used in **Boolean conditions** or expressions, that return either true or false.

The relational operators returns zero values or non-zero values. The zero values is taken as false, while the non-zero value is taken as true.

A simple relational expression contains only one relational operator and takes the following form : ,/p>

ae - 1 relational operator ae - 2

**ae - 1** and **ae - 2** are arithmetic expressions, which may be simple constants, variables or combination of them and arithmetic operators.

C supports six Relational operators and are as follows :

Operator |
Meaning |
---|---|

< | less than |

<= | less than or equal to |

> | greater than |

>= | greater than or equal to |

== | is equal to |

!= | is not equal to |

Relational operators are used to compare two quantities.,/p>

Relational operators are binary operators, because they act on two operands.

The operators <, <=, >, >= will be given the highest priority over ==, !=

when equal priority operators are there in an expression, the operators will be evaluated from left to right i.e they follow left to right associativity.

4.5 <= 10 true

4.5 < -10 false

-35 >= 0 false

10 < 7 + 5 true

(10+5) == (3*5) true

a + b == c + d true, only if the sum of values of a and b is equal to the sum of values of c and d.

When arithmetic expressions are used on either side of a relational operator, then the arithmetic expressions will be evaluated first and then the results will be compared. That is, arithmetic operators have a higher priority over relational operators.

Relational expressions are used in decision statements such as if and while to decide the course of action of a running program.

Among the six relational operators, each one is a complement of another operator.

> is complement of <=

< is complement of >=

== is complement of !=

< is complement of >=

== is complement of !=

We can simplify an expression involving the not and the relational operators using the complements as shown below :

Actual one |
Simplified one |
---|---|

!(x + y) | x >= y |

!(x > y) | x <= y |

!(x != y) | x == y |

!(x <= y) | x > y |

!(x >= y) | x < y |

!(x == y) | x != y |

Post Article

Upload Youtube Video

CLanguage

Friday, 31 Mar 2017

275

0

0

Popular Post

- Write an algorithm and draw the flowchart to find the largest number among the three numbers?
- Write an algorithm an draw flowchart to find factorial of a number?
- Write an algorithm and draw the flowchart to find whether a given number is even or odd?
- Write an algorithm and draw the flowchart to Swap two integers?
- Write an algorithm an draw the flowchart to compute the average of the three numbers?
- Write an algorithm and draw the flowchart to find the largest number amoug two numbers?
- write a c program to swap two numbers
- How to write a algorithm?
- What is mean by Operator Precedence and Associativity in C Language?
- C Languages Relational Operators

© 2019 - technotecode. All contents are copyright of their authors