Step 3

Click on the Step button and see what happens. Click on Reset to start again.

The assignment a = a + 1 works like this:
Get the value of a
Add 1
This is the new value of a

So the effect is to increase a by 1. This is sometimes called incrementing the variable.


Once you understand this, write these programs:

Program 3-1

Initialize a at 3
Increment a twice
Output a

Program 3-2

Decrementing a variable means reducing it by 1. Write a program which
Initializes b to be 3
Decrements b
Outputs b

Program 3-3

Write a program to:
Initialize a as 2 and b as 4
Increment a and decrement b
Output a and b

Index

Input:
Output:
Score:
Line
Statement
Var
Now
Next
1
a
 
2
b
 
3
c
 
4
d
 
5
e
 
6
7
8
9
10
11
12
13