Shortcut Mathematical Operators

By: Dusty Arlia
Published on August 23, 2012
Last Updated on Wednesday, July 15, 2015 at 1:14 PM
Total Updates: 10

Operator Example Its Equivalent What's Happening
+= score += 10 score = score + 10 Adds the value on the right side of the equal sign to the variable on the left.
-= score -= 10 score = score - 10 Subtracts the value on the right side of the equal sign from the variable on the left.
*= score *= 10 score = score * 10 Multiplies the variable on the left side of the equal sign to the value on the right side of the equal sign.
/= score /= 10 score = score / 10 Divides the value in the variable by the value on the right side of the equal sign.
++ score++ score = score + 1 When placed directly after the variable, ++ adds 1 to the variable.
-- score-- score = score - 1 When placed directly after the variable, -- subtracts 1 from the variable.

Comments:

Ad:

Ad: