To enter a string and count total number of vowels. (Qbasic Code)

To enter a string and count total number of vowels. (Qbasic Code)
  • CLS
    INPUT "Enter the string"; a$
    b$ = LCASE$(a$)
    FOR i = 1 TO LEN(b$)
        c$ = MID$(b$, i, 1)
        IF c$ = "a" OR c$ = "e" OR c$ = "i" OR c$ = "o" OR c$ = "u" THEN
            c = c + 1
        END IF
    NEXT i
    PRINT "The number of vowels in the string is "; c
    END

Next Method (Using SELECT CASE)
  • CLS
    INPUT "Enter the string"; a$
    b$ = LCASE$(a$)
    FOR i = 1 TO LEN(b$)
        c$ = MID$(b$, i, 1)
        SELECT CASE c$
            CASE "a", "e", "i", "o", "u"
                c = c + 1
        END SELECT
    NEXT i
    PRINT "The number of vowels in the string is "; c
    END 
See Also
Using SUB Procedure
Using  FUNCTION Procedure

Share :

Facebook Twitter Google+
Back To Top

facebook main

counter

Powered by Blogger.