Page 63 - iprime_V2.2_class8
P. 63
Example
Operator Description Syntax Output
(int a = 11, b = 4)
+ Returns the result after performing a + b a + b 15
(addition) addition
– Returns the result after performing a – b a – b 7
(subtraction) subtraction
* Returns the result after performing a * b a * b 44
(multiplication) multiplication
/ Returns the result after performing a / b a / b 2
(division) division
% Returns the remainder after a % b a % b 3
(modulus) performing division
Relational Operators
Relational operators help compare quantities and return the Boolean value ‘True’ or ‘False’ as
a result. These are also known as comparison operators.
Example
Operator Description Syntax Output
(int a = 11, b = 4)
== (equal to) To check equality between two (a == b) a == b false
values a == 11 true
!= To check inequality between two (a != b) a != b true
(not equal to) values a != 11 false
> To check if the first value is greater (a > b) (a > b) true
(greater than) than the second value (11 > 13) false
< To check if the first value is lesser (a < b) (a < b) false
(less than) than the second value
(15 < 20) true
>= To check if the first value is greater (a >= b) (a >= b) true
(greater than than or equal to the second value (22 >= 19) true
or equal to)
(21 >= 23) false
<= To check if the first value is lesser (a <= b) a <=b false
(less than or than or equal to the second value
(27 <= 26) false
equal to)
(30 <= 31) true
Program Coding 61

