To Count Vowels (Function Procedure) - Qbasic Code

To Count Vowels (Using Function Procedure) - Qbasic Code
  • DECLARE FUNCTION vowel(w$)
    CLS
    INPUT "Enter any word"; w$
    PRINT "The number of vowels is"; vowel(w$)
    END

    FUNCTION vowel (w$)
    w$ = LCASE$(w$)
    FOR i = 1 TO LEN(w$)
        c$ = MID$(w$, i, 1)
        IF c$ = "a" OR c$ = "e" OR c$ = "i" OR c$ = "o" OR c$ = "u" THEN
            n = n + 1
        END IF
    NEXT i
    vowel = n
    END FUNCTION

Share :

Facebook Twitter Google+
Back To Top

facebook main

counter

Powered by Blogger.