Assignment Operators Flashcards
=
Assigns values from the right side operands to the left side.
Ex: “c = a + b” assigns value of ‘a + b’ to ‘c’
+=
Add AND
Adds the right operand to the left operand and assigns the result to the left operand
Ex: “c += a” is equivalent to “c = c + a”
-=
Subtract AND
Subtracts the right operand from the left operand and assigns the result to the left operand.
Ex: “c -= a” is equivalent to “c = c - a”
*=
Multiply AND
Multiplies the right operand with the left operand and assigns the result to the left operand.
Ex: “c *= a” is equivalent to “c = c * a”
/=
Divide AND
Divides the left operand with the right operand and assigns the result to the left operand.
Ex: “c /= a” is equivalent to “ c = c / a”
%=
Modulus AND
Takes modulus using two operands and assigning the result to the left operand
Ex: “c %= a” is equivalent to “c = c % a”
**=
Exponent AND
Preforms exponential calculation on operators and assigns the value to the left operand.
Ex: “c **= a” is equivalent to “c = c ** a”
//=
Floor Division
Preforms floor division on operators and assigns the value to the left operand.
Ex: “c // a” is equivalent to c = “c // a”