130.
Write a program using FUNCTION….END FUNCTION to input a string and
count the total number of consonants.
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)
END
FUNCTION COUNT (S$)
CC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ <> "A" AND C$ <> "E" AND C$
<> "I" AND C$ <> "O" AND C$ <>
"U" THEN CC = CC + 1
NEXT I
COUNT = CC
END FUNCTION
No comments:
Post a Comment