QBASIC pattern program to print the stars in right angle triangle shape (SUB/FUNCTION)

3 months ago

In the world of programming, simplicity can often unveil incredible beauty. QBASIC, a language known for its simplicity and ease of use, becomes a canvas for creating stunning visual patterns. In this blog, we embark on a captivating journey through the cosmos of ascending pyramid patterns, exploring the magic of QBASIC through a concise and elegant code snippet. Join us as we unravel the code that paints a celestial pyramid on the digital canvas.

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

 

Using SUB Procedure

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

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

 

Using FUNCTION Procedure

DECLARE FUNCTION strPtrn
CLS
d = strPtrn
END

FUNCTION strPtrn 
a$ = "*****"
FOR i = 1 TO LEN(a$)
     PRINT LEFT$(a$, i)
NEXT i
END FUNCTION
  766