Page 62 - iPro_trackGPT_V5_Class8
P. 62
Relational Operators
Relational operators compare two values or quantities and return a 'true' or 'false' result. They
are also called comparison operators.
Example
Operator Description Syntax Output
(int a = 11, b = 4)
== This operator is used to check the (a == b) a == b false
Equal to equality between two values.
a == 11 true
!= This operator is used to check the (a != b) a != b true
Not Equal to inequality between two values.
a != 11 false
> This operator checks if the first value (a > b) (a > b) true
Greater than is greater than the second value.
(11 > 13) false
< This operator is used to check if the (a < b) (a < b) false
Less than first value is less than the second value.
(15 < 20) true
>= This operator is used to check if the (a >= b) (a >= b) true
greater than first value is greater than or equal to
(22 >= 22) true
or equal the second value.
(21 >= 23) false
<= This operator is used to check if the (a <= b) (a <= b) false
less than or first value is less than or equal to the
(30 <= 31) true
equal to second value.
(27 <= 27) true
Logical Operators
Logical operators are used to combine and evaluate multiple conditions. They return either ‘True’
or ‘False’ as the result.
Operator Description Syntax Example Output
&& (AND) Returns ‘true’ value if all the (a>b) && (b>c) (11 > 4) && (4 > 15) false
given conditions are true (11 > 4) && (15 > 4) true
|| (OR) Returns ‘true’ value if any (a>b) || (b>c) (11 > 4) || (4 > 15) true
one of the given conditions (11 > 4) || (15 > 4) true
is true (4 > 11) || (4 > 15) false
NOT (!) Returns ‘true’ value if the ! (a > b) !(11 > 4) false
condition returns false and !(4 > 11) true
vice-versa
Unary Operators
Unary operators are special operators that use only one operand or value to perform an operation.
Examples of unary operators include the increment (++) and decrement (--) operators, which
increase or decrease a value by one, respectively.
60 TrackGPT iPRO (V5.0)-VIII

