These are shortcuts for updating a variable using arithmetic.
The below table's right and left columns are equivalent
a += b
a -= b
a *= b
a /= b
a %= b
is equivalent to
is equivalent to
is equivalent to
is equivalent to
is equivalent to
a = a + b
a = a - b
a = a * b
a = a / b
a = a % b
Initialize a variable number with a value of 5.
Then, using augmented assignment operators:
Finally, print the result.
<aside> ⚖️ Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License.
If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact [email protected] for inquiries.
</aside>