Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops



Task

Document common flow-control structures.



One common example of a flow-control structure is the    goto    construct.

Note that   Conditional Structures   and   Loop Structures   have their own articles/categories.



Related tasks

   Conditional Structures
   Loop Structures 


    REM TinyBASIC has only two control flow structures: goto and gosub
    LET N = 0
 10 LET N = N + 1
    PRINT N
    IF N < 10 THEN GOTO 10
 
    LET R = 10
 
 15 IF N < 10000 THEN GOSUB 20
    IF N > 10000 THEN GOTO 30
    GOTO R + 5    REM goto can be computed
 
 20 LET N = N * 2
    PRINT N
    RETURN    REM gosub returns to where it was called from
              REM meaning it can be called from multiple
              REM places in the program
 
 30 LET N = 0
 40 GOSUB 105-N    REM gosub can be computed as well
    IF N <= 5 THEN GOTO 40
    END
 
100 PRINT "ZERO"
101 PRINT "1"
102 PRINT "22"
103 PRINT "333"
104 PRINT "4444"
105 PRINT "55555"
    LET N = N + 1
    RETURN    REM one return can serve several gosubs