Page 234 - IT-802_class_12
P. 234
Returns true if value of a is greater
> Greater Than a>b false
than that of b, false otherwise
Returns true if value of a is less than
< Less than a<b true
that of b, false otherwise
Returns true if value of a is greater than
>= Greater Than Equal to a>=b false
or equal to that of b, false otherwise
Returns true if value of a is greater than
<= Less Than Equal to a<=b true
or equal to that of b, false otherwise
3.3.3 Assignment Operator
The assignment operator is used to assign a value or an expression to a variable. The assignment operators are
discussed in the table given below:
Result (int a = 20,
Operator Description Explanation Example
b = 30)
Assigns value of left side operand to
= Simple Assignment a=b a becomes 30
right side operand
Adds value of left side operand to
Add and right side operand and assigns the a becomes 50
+= a+=b
Assignment result to the right-side operand Same (20+30)
as a = a+b
Subtracts value of left side operand
Subtract and from right side operand and assigns a becomes 10
-= a-=b
Assignment the result to the right-side operand (20-30)
Same as a = a-b
Multiplies value of left side operand
Multiply and to right side operand and assigns the a becomes 600
*= a*=b
Assignment result to the right side operand Same (20*30)
as a = a*b
Divides value of left side operand by
Divide and right side operand and assigns the a becomes 0
/= a/=b
Assignment quotient to the right side operand (20/30)
Same as a = a/b
Divides value of right side operand
Modulus and by left side operand and assigns the a becomes 20
%= a%=b
Assignment remainder to the right side operand (20%30)
Same as a = a%b
3.3.4 Logical Operators
A logical operator is used to check whether an expression results in true or false. There are three types of logical
operators. They are as follows:
Operator Description Explanation Example Result
Returns true if values of both a and b
&& Logical AND a&&b false
are true, false otherwise
Returns true if values of either a or b
|| Logical OR a||b true
is true, false otherwise
232 Touchpad Information Technology-XII

