Vtech PreComputer Power Pad Plus User Manual - Page 48

Input Give Me A Number;n, Print Your Number Is;n, Goto 10, For N=1 To 10, Print Hello, Next N,

Page 48 highlights

LOOPING A loop is a set of one or more instructions. These instructions can be repeated as many times as you want. You can create a loop with a GOTO statement. A program like the following will run continually: 10 INPUT "GIVE ME A NUMBER";N 20 PRINT "YOUR NUMBER IS";N 30 GOTO 10 RUN You can modify the program to get out of a loop by using an IF statement to control the loop like the program that calculates the area of a rectangle. Another way to create a loop is through the use of the FOR and NEXT statements. These statements surround the instructions that you want to repeat. For example, type the following: NEW 10 FOR N=1 TO 10 20 PRINT "HELLO" 30 NEXT N RUN press ENTER press ENTER press ENTER The word "HELLO" appears 10 times on the screen. You can change line 20 to print the value of N every time the loop repeats. Type: 20 PRINT "N IS";N press ENTER 44

  • 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

44
LOOPING
A loop is a set of one or more instructions.
These instructions can be repeated as many
times as you want.
You can create a loop with a
GOTO
statement.
A program like the following will run continually:
10
INPUT “GIVE ME A NUMBER”;N
20
PRINT “YOUR NUMBER IS”;N
30
GOTO 10
RUN
You can modify the program to get out of a loop by using an
IF
statement to control the
loop like the program that calculates the area of a rectangle.
Another way to create a loop is through the use of the
FOR
and
NEXT
statements.
These
statements surround the instructions that you want to repeat.
For example, type the following
:
NEW
10
FOR N=1 TO 10
press
ENTER
20
PRINT “HELLO”
press
ENTER
30
NEXT N
press
ENTER
RUN
The word “
HELLO
” appears 10 times on the screen.
You can change line 20 to print
the value of N every time the loop repeats.
Type
:
20
PRINT “N IS”;N
press
ENTER