Vtech PreComputer Power Pad Plus User Manual - Page 62

Print A; Is Greater Than; B:end

Page 62 highlights

Relations or comparisons used in the IF...THEN statement are the following: = Equal to < = Less than or equal to < > Not equal to > = Greater than or equal to < Less than > Greater than Examples of how you can use conditions: IF....THEN A=B IF....THEN GOTO IF....THEN GOSUB IF....THEN PRINT IF....THEN INPUT Example: 30 IF X >25 THEN 60 If the condition X>25 is true, the computer is told to go to line 60 (Note: the GOTO is optional after THEN). If the condition is not true, that is, if X is not greater than 25, then the computer simply carries on with the normal line number order in the program. Notice that it is not necessary to use the ELSE part of the command here, as this is optional. Example: 10 INPUT A,B 20 IF A > B THEN 50 30 IF A < B THEN 60 40 IF A = B THEN 70 50 PRINT A; "IS GREATER THAN"; B:END 60 PRINT A; "IS LESS THAN"; B: END 70 PRINT A; "IS EQUAL TO";B 80 END RUN ? 7 (pick a number) ?? 3 (pick a number) 7 IS GREATER THAN 3 58

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88

58
Relations or comparisons used in the
IF...THEN
statement are the following:
= Equal to
< = Less than or equal to
< > Not equal to
> = Greater than or equal to
< Less than
> Greater than
Examples of how you can use conditions:
IF
....
THEN A=B
IF
....
THEN GOTO
IF
....
THEN GOSUB
IF
....
THEN PRINT
IF
....
THEN INPUT
Example:
30
IF X >25 THEN 60
If the condition X>25 is true, the computer is told to go to line 60 (Note: the
GOTO
is
optional after
THEN
).
If the condition is not true, that is, if X is not greater than 25, then the computer simply
carries on with the normal line number order in the program.
Notice that it is not necessary
to use the
ELSE
part of the command here, as this is optional.
Example:
10
INPUT A,B
20
IF A > B THEN 50
30
IF A < B THEN 60
40
IF A = B THEN 70
50
PRINT A; “IS GREATER THAN”; B:END
60
PRINT A; “IS LESS THAN”; B: END
70
PRINT A; “IS EQUAL TO”;B
80
END
RUN
? 7
(pick a number)
?? 3
(pick a number)
7 IS GREATER THAN 3