Relational Operators

Default Image

s it is expressed from the name of
operators these symbols are used to express some relation between two
variables or quantities. In other words, we can say these symbols are
used to compare. C++ have six operators that are used to compare values.
To understand these operators work let’s assume four variables with
values i.e. a=3, b=6, c=3, d=2.












































Operator


Named As Working Example

==


Equal to Checks both values and return true if both are equal else false a==c returns true

a==b returns false

!=


Not Equal to Checks both values and return true if both are not equal else false. a!=b returns true

a!=c returns false

<


Less then Checks both values and return true if left side is smaller else false. a a

>


Grater then Checks both values and return true if left side is bigger else false. a>d returns true

a>b returns false

<=


Less than or Equal Checks both values and return true if left side is smaller or equal. a<=b returns true

a<=c returns true

a<=d returns false

>=


Greater than or Equal Checks both values and return true if left side is greater or equal a>=d returns true

a<=c returns true

a<=b returns false

Read Count: 3 times

Comments

No comments yet.

Leave a Comment