Saturday, October 20, 2012

Use of post-test loops

In addition to the pre-test loops, QBASIC has post-test loops. The post-test loops look very similar to their pre-test cousins.

This is the syntax for DO...LOOP WHILE

DO
     ' BASIC code statements here
LOOP WHILE c

where
c = a condition is which must be met
    in order to halt repetition


Another way to get exactly the same output is by using DO...LOOP UNTIL.

DO
     ' BASIC code statements here
LOOP UNTIL c

where
c = a condition is which must be met
    in order to halt repetition


Both of these loops produce the same output as the pre-test loops.