The
assignment operators are used to assigning the value of the right expression to
the left operand. The assignment operators are described in the following
table.
Operator
|
Description
|
=
|
It assigns the value of the right
expression to the left operand.
|
+=
|
It increases the value of the left
operand by the value of the right operand and assign the modified value back
to left operand. For example, if a = 10, b = 20 => a+ = b will be equal to
a = a+ b and therefore, a = 30.
|
-=
|
It decreases the value of the left
operand by the value of the right operand and assign the modified value back
to left operand. For example, if a = 20, b = 10 => a- = b will be equal to
a = a- b and therefore, a = 10.
|
*=
|
It multiplies the value of the left
operand by the value of the right operand and assign the modified value back
to left operand. For example, if a = 10, b = 20 => a* = b will be equal to
a = a* b and therefore, a = 200.
|
%=
|
It divides the value of the left
operand by the value of the right operand and assign the reminder back to
left operand. For example, if a = 20, b = 10 => a % = b will be equal to a
= a % b and therefore, a = 0.
|
**=
|
a**=b will be equal to a=a**b, for
example, if a = 4, b =2, a**=b will assign 4**2 = 16 to a.
|
//=
|
A//=b will be equal to a = a// b, for
example, if a = 4, b = 3, a//=b will assign 4//3 = 1 to a.
|
0 comments:
Post a Comment