Fiveable
Fiveable

Compound Assignment Operators

Definition

Compound assignment operators are shorthand notations that combine an arithmetic operation with the assignment operator. They allow you to perform an operation and assign the result to a variable in a single step.

Analogy

Think of compound assignment operators as shortcuts on your phone's keyboard. Instead of typing out a long message, you can use emojis or abbreviations to convey the same meaning in a shorter and more efficient way.

Related terms

+= operator: This operator adds the value on the right side of it to the variable on the left side, and then assigns the result back to that variable.

-= operator: This operator subtracts the value on the right side of it from the variable on the left side, and then assigns the result back to that variable.

*= operator: This operator multiplies the value on the right side of it with the variable on the left side, and then assigns the result back to that variable.

collegeable - rocket pep

Are you a college student?

  • Study guides for the entire semester

  • 200k practice questions

  • Glossary of 50k key terms - memorize important vocab



© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.


© 2024 Fiveable Inc. All rights reserved.

AP® and SAT® are trademarks registered by the College Board, which is not affiliated with, and does not endorse this website.