QBASIC Program to print the pattern 11111, 1111, 111, 11, 1 (SUB/FUNCTION)

3 months ago

QBASIC, with its straightforward syntax, provides a canvas for crafting beautiful patterns. In this blog, we explore the enchanting realm of descending numerical patterns, unveiling the magic within a concise QBASIC program that uses SUB and FUNCTION. Join us as we decode the symmetrical beauty of the pattern 11111, 1111, 111, 11, 1.

CLS
n = 11111
FOR i = 1 TO 5
     PRINT n
     n = n \ 10
NEXT i
END

 

Using SUB Procedure

DECLARE SUB pattern() CLS
CALL pattern
END

SUB pattern
n = 11111
FOR i = 1 TO 5
     PRINT n
     n = n \ 10
NEXT i
END SUB

 

Using FUNCTION Procedure

DECLARE FUNCTION pattern()
CLS
d = pattern
END

FUNCTION pattern
n = 11111
FOR i = 1 TO 5
     PRINT n
     n = n \ 10
NEXT i
END FUNCTION
  742