To generate the given pattern
C
CO
COM
COMP
COMPU
COMPUT
COMPUTE
COMPUTER
Using SUB Procedure
C
CO
COM
COMP
COMPU
COMPUT
COMPUTE
COMPUTER
- CLS
LET a$ = "COMPUTER"
FOR i = 1 TO LEN(a$)
PRINT LEFT$(a$, i)
NEXT i
END
DECLARE SUB pattern (a$)
CLS
CALL pattern(a$)
END
SUB pattern (a$)
LET a$ = "COMPUTER"
FOR i = 1 TO LEN(a$)
PRINT LEFT$(a$, i)
NEXT i
END SUB
CLS
CALL pattern(a$)
END
SUB pattern (a$)
LET a$ = "COMPUTER"
FOR i = 1 TO LEN(a$)
PRINT LEFT$(a$, i)
NEXT i
END SUB
Using FUNCTION Procedure
- Without parameters
- DECLARE FUNCTION pattern ( )
CLS
p = pattern
END
FUNCTION pattern
a$ = "COMPUTER"
FOR i = 1 TO LEN(a$)
PRINT LEFT$(a$, i)
NEXT i
END FUNCTION
- With parameters
- DECLARE FUNCTION pattern$(a$)
CLS
p$ = pattern$(a$)
END
FUNCTION pattern$ (a$)
a$ = "COMPUTER"
FOR i = 1 TO LEN(a$)
PRINT LEFT$(a$, i)
NEXT i
END FUNCTION