Beginner's Programming Tutorial in QBasic

(Kiana) #1
LOOP

They both output:
10


(^1112)
13
14
If you place the expression at the end of the loop instead, the program goes through the loop atleast once.
x = 32
DO
PRINT x
x = x + 1
LOOP WHILE x < 5
This is the output because the loop was only gone through one time:
32


FOR...NEXT


FOR...NEXT provides an easier way to create a loop.
FOR x = 1 TO 5
PRINT x
NEXT x
Output:
1


(^23)
4
5
TIP: The X after NEXT is optional (unless you
have a loop within a loop).

Free download pdf