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

DECLARE SUB MERGE (A%(), NA%, B%(), NB%, C%())
DEFINT A-Z
CLS : NA = 3: DIM A(NA): DATA 0,2,4
FOR K = 0 TO NA - 1: READ A(K): PRINT A(K); : NEXT K: PRINT
NB = 4: DIM B(NB): DATA 1,3,5,7
FOR K = 0 TO NB - 1: READ B(K): PRINT B(K); : NEXT K: PRINT
DIM C(NA + NB)
MERGE A(), NA, B(), NB, C()
FOR K = 0 TO NA + NB - 1: PRINT C(K); : NEXT K
END

SUB MERGE (A(), NA, B(), NB, C())
JA = 0: JB = 0
FOR JC = 0 TO NA + NB - 1
  IF JA = NA THEN GOTO MB
  IF JB = NB THEN GOTO MA
  IF A(JA) < B(JB) THEN GOTO MA
MB: C(JC) = B(JB): JB = JB + 1: GOTO M1
MA: C(JC) = A(JA): JA = JA + 1:
M1:
NEXT JC
END SUB