int count = 0;
count = count + 2;
Decrementing is also possible. A decrement involves decreasing the value of the variable
by a xed amount.
Incrementing and decrementing are so common in programming that most languages
provide shortcuts for them. In RobotC, we can also use
int count = 0;
count += 1;
to increment by 1 (or any value we choose). Even shorter, we can use
int count = 0;
count ++;
to increment by 1 (and only 1 with this syntax). There are similar operators for decrementing,
-= and --.
No comments:
Post a Comment