June 2017
Beginner
1296 pages
69h 23m
English
The compound assignment operators enable you to abbreviate assignment expressions. For example, you can abbreviate the statement
c = c + 3; // adds 3 to c
with the addition compound assignment operator, +=, as
c += 3; // adds 3 to c more concisely
The += operator adds the value of the expression on its right to the value of the variable on its left and stores the result in the variable on the left. Thus, the assignment expression c+=3 adds 3 to c. In general, statements like
variable = variable operator expression;
where operator is one of the binary operators +, -, *, / or % (or others we discuss later in the text) and the same variable name is used can be written in the form
variable operator= expression ...