Site pages
Current course
Participants
General
Topic 1
Topic 2
Topic 3
Topic 4
Topic 5
Topic 6
Topic 7
Topic 8
Topic 9
Topic 10
Topic 11
Topic 12
Topic 13
Topic 14
Topic 15
Topic 16
Topic 17
Topic 18
Topic 19
Topic 20
Topic 21
Topic 22
Topic 23
Topic 24
Topic 25
Topic 26
Topic 27
Topic 28
Topic 29
Topic 30
Topic 31
Topic 32
Topic 33
Topic 34
Topic 35
The ON-GoTo Statement
This statement is a conditional branch transfer type of statement. The transfer of control depends on the value of the expression which is a part of this statement.
The general form is v -- may be a constant, a variable, or an expression n1, n2, …np – are labels of other statements in a program. The labels n1, n2, …np must be separated from each other by a comma. This statement functions as follows When v =1, control goes to statement labeled n1, When v =2, control goes to statement labeled n2, ……………. ………….. When v =p, control goes to statement labeled np. Program 10 LET X=3 20 ON X GOTO 80, 60, 30 30 PRINT X 40 X=X-1 50 GOTO 20 60 PRINT X 70 GOTO 40 80 PRINT X 90 STOP 100 END Output 3 2 1 |
Last modified: Wednesday, 18 January 2012, 10:45 PM