STRING PATTERN SUB PROCEDURE


CLICK HERE TO FIND OUT NUMERIC PATTERNS USING SUB PROCEDURE

CLICK HERE TO FIND OUT  NUMERIC PATTERNS IN QBASIC (WITHOUT SUB OR FUNCTION)

CLICK HERE TO FIND OUT  STRING PATTERNS IN QBASIC (WITHOUT SUB OR FUNCTION)


N

NE

NEP

NEPA

NEPAL

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = 1 TO LEN(S$)

PRINT LEFT$(S$, I)

NEXT I

END SUB


L

AL

PAL

EPAL

NEPAL

DECLARE SUB PATTERN (S$)
CLS
S$ = “NEPAL”
CALL PATTERN(S$)
END

SUB PATTERN (S$)
FOR I = 1 TO LEN(S$)
PRINT RIGHT$(S$, I)
NEXT I
END SUB


NEPAL

EPAL

PAL

AL

L

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = LEN(S$) TO 1 STEP – 1

PRINT RIGHT$(S$, I)

NEXT I

END SUB


NEPAL

NEPA

NEP

NE

N

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = LEN(S$) TO 1 STEP – 1

PRINT LEFT$(S$, I)

NEXT I

END SUB


N

E

P

A

L

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = 1 TO LEN(S$)

PRINT MID$(S$, I, 1)

NEXT I

END SUB


L

A

P

E

N

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = LEN(S$) TO 1 STEP -1

PRINT MID$(S$, I, 1)

NEXT I

END SUB


N

   E

      P

        A

            L

DECLARE SUB PATTERN (S$)
CLS
S$ = “NEPAL”
CALL PATTERN(S$)
END

SUB PATTERN (S$)
FOR I = 1 TO LEN(S$)
PRINT TAB(I); MID$(S$, I, 1)
NEXT I
END SUB


L

   A

      P

        E

            N

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

B = 1

FOR I = LEN(S$) TO 1 STEP -1

PRINT TAB(B); MID$(S$, I, 1)

B = B + 1

NEXT I

END SUB


NEPAL

EPA

P

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

A = 1

FOR I = LEN(S$) TO 1 STEP -2

PRINT MID$(S$, A, I)

A = A + 1

NEXT I

END SUB


PROGRAMMING

ROGRAMMIN

OGRAMMI

GRAMM

RAM

RM

A

  DECLARE SUB PATTERN (S$)
CLS
S$ = “PROGRAMMING”
CALL PATTERN(S$)
END

SUB PATTERN (S$)
A = 1
FOR I = LEN(S$) TO 1 STEP -2
PRINT TAB(A); MID$(S$, A, I)
A = A + 1
NEXT I
END SUB


   P

EPA

NEPAL

DECLARE SUB PATTERN (S$)

CLS

S$ = “NEPAL”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

A = 3

FOR I = 1 TO LEN(S$) STEP 2

PRINT TAB(A); MID$(S$, A, I)

A = A – 1

NEXT I

END SUB


*

**

***

****

*****

******

*******

DECLARE SUB PATTERN (S$)

CLS

S$ = “*******”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = 1 TO LEN(S$)

PRINT LEFT$(S$, I)

NEXT I

END SUB


*******

******

*****

****

***

**

*

DECLARE SUB PATTERN (S$)

CLS

S$ = “*******”

CALL PATTERN(S$)

END

SUB PATTERN (S$)

FOR I = LEN(S$) TO 1 STEP -1

PRINT LEFT$(S$, I)

NEXT I

END SUB


*

**

***

****

*****

*

**

***

****

*****

*

*

*

*

*

DECLARE SUB PATTERN1 (S$)
DECLARE SUB PATTERN (S$)
CLS
S$ = “*****”
CALL PATTERN(S$)
CALL PATTERN(S$)
CALL PATTERN1(S$)
END

SUB PATTERN (S$)
FOR I = 1 TO LEN(S$)
PRINT LEFT$(S$, I)
NEXT I
END SUB

SUB PATTERN1 (S$)
FOR K = 1 TO LEN(S$)
PRINT MID$(S$, K, 1)
NEXT K

END SUB