Home QBASIC C Java HTML
  • More Courses
  • MCQs
  • Blog Download
  • Tools
  • Contact

    QBASIC Pattern Printing Program, P, EPA, NEPAL

    Posted on 2021-06-04

    QBASIC pattern printing program example with SUB ... END SUB and FUNCTION .... END FUNCTION                                                                                                                                                                         

    Program

    CLS
    S$ = "NEPAL"
    r = 1
    t = 10
    FOR i = 3 TO 1 STEP -1
        PRINT TAB(t); MID$(S$, i, r)
        r = r + 2
        t = t - 1
    NEXT i
    END
    

    Output

      P
     EPA
    NEPAL
    

    Using SUB ... END SUB

    Program

    DECLARE SUB pat(s$)CLS
    S$ = "NEPAL"
    CALL pat(S$)
    END
    
    SUB pat (s$)
        r = 1
        t = 10
        FOR i = 3 TO 1 STEP -1
            PRINT TAB(t); MID$(s$, i, r)
            r = r + 2
            t = t - 1
        NEXT i
    END SUB
    

    Output

      P
     EPA
    NEPAL
    

    Using FUNCTION... END FUNCTION

    Program

    DECLARE FUNCTION pat$()
    CLS
    p$ = pat$
    END
    
    FUNCTION pat$ ()
        r = 1
        t = 10
        s$ = "NEPAL"
        FOR i = 3 TO 1 STEP -1
            PRINT TAB(t); MID$(s$, i, r)
            r = r + 2
            t = t - 1
        NEXT i
    END FUNCTION
    
    
    

    Output

      P
     EPA
    NEPAL
    

    1290