Written by the Fiveable Content Team โข Last updated September 2025
Verified for the 2026 exam
Verified for the 2026 examโขWritten by the Fiveable Content Team โข Last updated September 2025
Definition
A compound assignment operator is a shorthand way to combine an arithmetic operation with the assignment operation. It performs the specified arithmetic operation on the value of the variable and assigns the result back to the same variable.
Related terms
Addition: The compound assignment operator for addition is "+=". It adds the value on the right side of the operator to the current value of the variable and assigns the result back to that variable.
Subtraction: The compound assignment operator for subtraction is "-=". It subtracts the value on the right side of the operator from the current value of the variable and assigns the result back to that variable.
Division: The compound assignment operator for division is "/=". It divides (integer division) or divides and assigns (floating-point division) by dividing the value on the right side of the operator from the current value of the variable and assigns the result back to that variable.