Home  |  IT Zone  |  Tips / Tricks  |  Did You Know  |  Inspirational  |  Health  |  World Infos  |  Insurance  |  Universities  |  Forex  |  Mathematics  |  Illusions  |  Children Day Quotes  |  Fun / Jokes  |  Decent Quotes  |  Birthday Msgs  |  Good Morning Msgs  |  Good Night Msg  |  Husband Wife Jokes  |  Teacher Students Jokes  |  Insult Jokes  |  Love Quotes  |  Sad Quotes  |  Funny Pics  |  Be Aware  |  Articles  |  Simple Joys of Life 

To print a string in diminishing pattern (Qbasic Code)

Diminishing pattern: that each line is a character less than its previous till a single character is printed in the last line.

REM prints diminishing pattern from string
Using For .... Next Statement
CLS
INPUT "Enter a string"; s$
l = LEN(s$)
FOR i = l TO 1 STEP -1
        PRINT LEFT$(s$, i)
NEXT i
END
END

Using While .. Wend Loop
CLS
INPUT "Enter a string"; s$
l = LEN(s$)
WHILE l > 0
PRINT LEFT$(s$, l)
l = l - 1
WEND
END

Share :

Twitter
Back To Top

facebook main

Powered by Blogger.