Step 2

This program uses input statements. These read in values when they execute

The input data might come from the keyboard, or from a file, or across a network. In this version, the input values come from the input box below. It will input 2 values, and they must be in the input box, separated by commas, before the program starts. For example, the input box might contain 4,5

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

How do we choose the input values? Anything we like, so long as they are two numbers. This includes decimals like 2.5 and negative values like -3.

The pattern of this program is
Input values
Calculate result
Output the result

Once you understand this, write these programs:

Program 2-1

Input values for a and b
Make c equal to a minus b : that is a-b
Output c

Program 2-2

Finding the average of two input numbers, by adding them up and dividing by 2:
Input a and b
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 2-3

Write a program to change inches to centimeters. We have to multiply by 2.54. So..
Input a : this is the number of inches
Make b equal to 2.54 * a : this is the centimeters
Output b

Program 2-4

Write a program to change Fahrenheit temperatures to Centigrade. We have to subtract 32, then multiply by 5/9. So..
Input a : this is the Fahrenheit
Make b equal to (a-32)*5/9 : this is the Centigrade
Output b

We can include words in the output, if we say
output "In Centigrade this is "+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