Примеры программ на языке QBASIC

DECLARE SUB BUBBLE1 (X%(), N%)
DEFINT A-Z
CLS
DIM A(20)
FOR J = 0 TO 19: A(J) = INT(20 * RND): PRINT USING "####"; A(J); : NEXT J
PRINT
BUBBLE1 A(), 20
FOR J = 0 TO 19: PRINT USING "####"; A(J); : NEXT J
END

SUB BUBBLE1 (X(), N)
M: Q = 0
   FOR I = 1 TO N - 1
     IF X(I - 1) > X(I) THEN
      TMP = X(I - 1): X(I - 1) = X(I): X(I) = TMP: Q = 1
    END IF
   NEXT I
   IF Q = 1 THEN GOTO M
END SUB