QBASIC PROGRAM TO COUNT TOTAL NUMBER OF VOWELS ,CONSONANTS AND WORDS FROM A STRING
CLS
INPUT ENTER ANY STRING; S$
VC = 0
CC = 0
WC = 1
SC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ = A OR C$ = E OR C$ = I OR C$ = O OR C$ = U THEN
VC = VC + 1
ELSEIF B$ = THEN
WC = WC + 1
ELSEIF B$ = . THEN
SC = SC + 1
ELSE
CC = CC + 1
END IF
NEXT I
PRINT TOTAL NO. OF VOWELS= ; VC
PRINT TOTAL NO. OF CONSONANTS=; CC
PRINT TOTAL NO. OF WORDS=; WC
END
USING SUB
DECLARE SUB VCW(S$)
CLS
INPUT ENTER ANY STRING; S$
CALL VCW(S$)
END
SUB VCW(S$)
VC = 0
CC = 0
WC = 1
SC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
C$ = UCASE$(B$)
IF C$ = A OR C$ = E OR C$ = I OR C$ = O OR C$ = U THEN
VC = VC + 1
ELSEIF B$ = THEN
WC = WC + 1
ELSEIF B$ = . THEN
SC = SC + 1
ELSE
CC = CC + 1
END IF
NEXT I
PRINT TOTAL NO. OF VOWELS= ; VC
PRINT TOTAL NO. OF CONSONANTS=; CC
PRINT TOTAL NO. OF WORDS=; WC
END SUB
0 Comments