Program to print 1, 2 3, 4 5 6, 7 8 9 10 numeric pattern in QBASIC Programming. This numeric pattern is also called Floyd's Triangle. Writing a computer program to produce this triangle has been frequently used as an exercise or example for beginning computer programmers, covering the concepts of text formatting and simple loop constructs.
Simple QBASIC Program
CLS
k = 1
FOR i = 1 TO 4
FOR j = 1 TO i
PRINT k;
k = k + 1
NEXT j
PRINT
NEXT i
END
Output
1
2 3
4 5 6
7 8 9 10
Using SUB .... END SUB (Sub Procedure)
DECLARE SUB pattern(n)
CLS
k = 1
CALL pattern(k)
END
SUB pattern (k)
FOR i = 1 TO 4
FOR j = 1 TO i
PRINT k;
k = k + 1
NEXT j
PRINT
NEXT i
END SUB
Using FUNCTION ... END FUNCTION (Function Procedure)
DECLARE FUNCTION pattern()
CLS
c = pattern
END
FUNCTION pattern ()
k = 1
FOR i = 1 TO 4
FOR j = 1 TO i
PRINT k;
k = k + 1
NEXT j
PRINT
NEXT i
END FUNCTION
6848