QBASIC Program to input any string from the user and count and print the total number of consonant letter.
CLS
INPUT "Enter any String : "; s$
c = 0
FOR i = 1 TO LEN(s$)
r$ = MID$(s$, i, 1)
c$ = UCASE$(r$)
IF c$ <> "A" AND c$ <> "E" AND c$ <> "I" AND c$ <> "O" AND c$ <> "U" AND c$ <> " " THEN
c = c + 1
INPUT "Enter any String : "; s$
c = 0
FOR i = 1 TO LEN(s$)
r$ = MID$(s$, i, 1)
c$ = UCASE$(r$)
IF c$ <> "A" AND c$ <> "E" AND c$ <> "I" AND c$ <> "O" AND c$ <> "U" AND c$ <> " " THEN
c = c + 1
END IF
NEXT i
PRINT "Total Number of Consonant Letter is : "; c
END
NEXT i
PRINT "Total Number of Consonant Letter is : "; c
END
Using SUB Procedure
DECLARE SUB VowelCount(s$)
CLS
INPUT "Enter any String : "; s$
CALL VowelCount(s$)
END
SUB VowelCount (s$)
c = 0
FOR i = 1 TO LEN(s$)
r$ = MID$(s$, i, 1)
c$ = UCASE$(r$)
IF c$ <> "A" AND c$ <> "E" AND c$ <> "I" AND c$ <> "O" AND c$ <> "U" AND c$ <> " " THEN
c = c + 1
END IF
NEXT i
PRINT "Total Number of Consonant Letter is : "; c
END SUB
INPUT "Enter any String : "; s$
CALL VowelCount(s$)
END
SUB VowelCount (s$)
c = 0
FOR i = 1 TO LEN(s$)
r$ = MID$(s$, i, 1)
c$ = UCASE$(r$)
IF c$ <> "A" AND c$ <> "E" AND c$ <> "I" AND c$ <> "O" AND c$ <> "U" AND c$ <> " " THEN
c = c + 1
END IF
NEXT i
PRINT "Total Number of Consonant Letter is : "; c
END SUB
Using FUNCTION Procedure
DECLARE FUNCTION VowelCount(s$)
CLS
INPUT "Enter any String : "; s$
PRINT "Total Number of Consonant Letter is : "; VowelCount(s$)
END
FUNCTION VowelCount (s$)
c = 0
FOR i = 1 TO LEN(s$)
r$ = MID$(s$, i, 1)
c$ = UCASE$(r$)
IF c$ <> "A" AND c$ <> "E" AND c$ <> "I" AND c$ <> "O" AND c$ <> "U" AND c$ <> " " THEN
c = c + 1
CLS
INPUT "Enter any String : "; s$
PRINT "Total Number of Consonant Letter is : "; VowelCount(s$)
END
FUNCTION VowelCount (s$)
c = 0
FOR i = 1 TO LEN(s$)
r$ = MID$(s$, i, 1)
c$ = UCASE$(r$)
IF c$ <> "A" AND c$ <> "E" AND c$ <> "I" AND c$ <> "O" AND c$ <> "U" AND c$ <> " " THEN
c = c + 1
END IF
NEXT i
VowelCount = c
END FUNCTION
NEXT i
VowelCount = c
END FUNCTION
No comments:
Post a Comment
If you have any doubts, Please let me know.