
Operators and Expressions II-45
Table 3.7 Assignment Operators
=
*= /= %=
+=
– =
<<= >>=
17. What are compound assignment operators?
Ans: A compound assignment operator consists of a binary operator and assignment operator.
They carry out binary operation and assign the result to the left operand.
Compound assignment operators and equivalent expressions are as follows:
a += b is equivalent to a = a + b
a −= b is equivalent to a = a − b
a *= b is equivalent to a = a * b
a /= b is equivalent to a = a/b
a %= b is equivalent to a = a%b
a <<= b is equivalent to a = a << b
a >>= b is equivalent to a = a >> b
a &= b is equivalent to a = a&b
a |= b is equivalent ...