Locked lesson.
About this lesson
We learn how to increment and decrement variables using ++ and -- commands.
Exercise files
Download this lesson’s related exercise files.
17 - Math Incrementation ++ and --.docx60.9 KB 17 - Math Incrementation ++ and -- SOLUTION.docx
58.1 KB
Quick reference
Math Incrementation ++ and --
++ Increment and -- Decrement allow you to add 1 or subtract 1 to a variable.
When to use
Use this generally to create counters.
Instructions
int x = 4;
x++ // add one later
++x // add one now
x-- // subtract one later
--x // subtract one now
Hints & tips
- x++
- ++x
- x--
- --x
Lesson notes are only available for subscribers.