Download Print this page

VTech PreComputer 2000 Manual page 29

Advertisement

A condition is either TRUE or FALSE. The IF statement has a condition. The
computer evaluates the condition and decides that if -a condition is TRUE it will
do something for the TRUE condition
.
Take the following:
I
1F A > 90 THEN PRINT "YOU ARE SMART"
The A
>
90 is a condition. The PRINT "YOU ARE SMART" is the thing it does
for the true condition. In the above example, let's give A the value 80. Would
the message be printed? No, it would not be printed because the condition is
false (80 is less than 90).
Let's try a
program to compute the area of a rectangle
.
Type:
NEW
10 INPUT "ENTER THE LENGTH";L
20 INPUT "ENTER WIDTH";W
40 PRINT "THE AREA IS";A
50 INPUT "ANOTHER? (Y/N)";R$
60 IF R$="Y" THEN 10
70 PRINT "THAT'S ALL FOLKS!"
80 END
This program uses the INPUT statement to get values for numeric variables and
print a computed result. It then prompts for a string variable and makes the
decision to begin again if the value typed in is a
Y.
28

Advertisement

loading