QBASIC PROGRAM TO FIND TOTAL NO. OF CONSONANTS IN A STRING
CLS
INPUT "ENTER ANY STRING"; 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" AND C$ < > " " AND C$ < > "." THEN
CC = CC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF CONSONANTS= "; CC
END
USING SUB
DECLARE SUB CONSONANT(S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL CONSONANT(S$)
END
SUB CONSONANT(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" AND C$ < > " " AND C$ < > "." THEN
CC = CC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF CONSONANTS= "; CC
END SUB
0 Comments