Beginner's Programming Tutorial in QBasic

(Kiana) #1

TheLabel:
PRINT "3"
RETURN
(Note: The END command exits the program.)
Since the program returns to the GOSUB command, the number 2 is printed this time.


(^13)
2


Line numbers


"Line numbers" can be used as labels.
PRINT "1"
GOTO 10
PRINT "2"
10 PRINT "3" (Notice the line number)


You can also write the program like this:
10 PRINT "1"
20 GOTO 40
30 PRINT "2"
40 PRINT "3"


The line numbers don't even have to be in sequence.
17 PRINT "1"
2 GOTO 160
701 PRINT "2"
160 PRINT "3"
Each of these programs output:


(^13)

Free download pdf