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 input string in alternate capital letters using FUNCTION procedure.

To print input string in alternate capital letters using FUNCTION procedure. (if user inputs 'COMPUTER' then the output should be 'CoMpUtEr') (QBasic Code)
  • DECLARE FUNCTION alternate$(a$)
    CLS
    INPUT "Enter string:"; a$
    PRINT "The required alternate is: "; alternate$(a$)
    END

    FUNCTION alternate$ (a$)
    FOR i = 1 TO LEN(a$)
        b$ = MID$(a$, i, 1)
        IF i MOD 2 = 0 THEN
            b$ = LCASE$(b$)
        ELSE
            b$ = UCASE$(b$)
        END IF
        alt$ = alt$ + b$
    NEXT i
    alternate$ = alt$
    'PRINT "The required alternate is: "; alt$
    END FUNCTION

Share :

X
Back To Top

facebook main

Powered by Blogger.