QBASIC pattern program to print *****, ****, ***, **, * (SUB/FUNCTION)

3 months ago

In this blog, we'll embark on a journey through the stars, exploring a mesmerizing pyramid pattern crafted with just a handful of lines of QBASIC code. Brace yourself for a captivating expedition into the world of simplicity and creativity.

CLS
a$ = "*****"
FOR i = LEN(a$) TO 1 STEP -1
     PRINT LEFT$(a$, i)
NEXT i
END

 

Using SUB Procedure

DECLARE SUB pattern(a$)
CLS
a$ = "*****"
CALL pattern(a$)
END

SUB pattern (a$)
FOR i = LEN(a$) TO 1 STEP -1
     PRINT LEFT$(a$, i)
NEXT i
END SUB

 

Using FUNCTION Procedure

DECLARE FUNCTION pattern()
CLS
d = pattern
END

FUNCTION pattern
a$ = "*****"
FOR i = LEN(a$) TO 1 STEP -1
     PRINT LEFT$(a$, i)
NEXT i
END FUNCTION

 

  483