Step 1
This program has 4 instructions, or statements, each on a different line.
It uses 3 variables, called a b and c. The values of these variables change as the instructions are carried out. The current values of the variables is shown in the column headed 'Now', shown on the right. Click on the Step button and see what happens. Click on Reset to start again. When you have the idea, type in what you think the next values of the variables will be before you click Step. The cell goes green if you were right, and your score goes up. The pattern of this program is Initialise variables Calculate result Output the result Once you understand this, write these programs: Program 1-1Initialise a as 2 and b as 3
Make c equal to a times b (use * for multiply) Output c Program 1-2Finding the average of two numbers, by adding them up and dividing by 2:
Initialise a as 2 and b as 4 Make c equal to (a+b)/2 .. we need the brackets so it adds first Output c Try other values of a and b to check it works Program 1-3Finding the volume of a cuboid:
Index
Initialise a as 2, b as 3, c as 4 Make d equal to a times b times c Output d |
|