One program to count the character, vowel and consonant from a word using function
count = 0
Declare function vowel(a$)
Declare function consonant(a$)
CLS
INPUT "Enter a String"; a$
PRINT "Total number of character in given string is ="; LEN(a$)
PRINT "Total number of Vowels in given string is ="; Vowel(a$)
PRINT "Total number of Consonant in given string is ="; consonant(a$)
END
FUNCTION Vowel (a$)
c = LEN(a$)
FOR i = 1 TO c
b$ = (MID$(a$, i, 1))
IF (b$ = "A" OR b$ = "a" OR b$ = "E" OR b$ = "e" OR b$ = "I" OR b$ = "i" OR b$ = "O" OR b$ = "o" OR b$ = "U" OR b$ = "u") THEN
count = count + 1
END IF
NEXT i
Vowel = count
END FUNCTION
FUNCTION consonant (a$)
c = LEN(a$)
FOR i = 1 TO c
d$ = (MID$(a$, i, 1))
IF (d$ <> "A" AND d$ <> "a" AND d$ <> "E" AND d$ <> "e" AND d$ <> "I" AND d$ <> "i" AND d$ <> "O" AND d$ <> "o" AND d$ <> "U" AND d$ <> "u") THEN
count = count + 1
END IF
NEXT i
consonant = count
END FUNCTION
0 Comments
Thank You ! For your love