QBASIC Program to input any string from the user and count the total number of vowel letters from the given string and print the total number of vowel 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" OR c$ = "E" OR c$ = "I" OR c$ = "O" OR c$ = "U" 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" OR c$ = "E" OR c$ = "I" OR c$ = "O" OR c$ = "U" THEN
c = c + 1
END IF
NEXT i
PRINT "Total Number of Vowel Letter is : "; c
END
NEXT i
PRINT "Total Number of Vowel Letter is : "; c
END
Using SUB Procedure
DECLARE SUB VowelCount(s$)
CLS
INPUT "Enter any String : "; s$
CALL VowelCount(s$)
END
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" OR c$ = "E" OR c$ = "I" OR c$ = "O" OR c$ = "U" THEN
c = c + 1
END IF
NEXT i
PRINT "Total Number of Vowel Letter is : "; c
END SUB
NEXT i
PRINT "Total Number of Vowel Letter is : "; c
END SUB
Using FUNCTION Procedure
DECLARE FUNCTION VowelCount(s$)
CLS
INPUT "Enter any String : "; s$
PRINT "Total Number of Vowel Letter is : "; VowelCount(s$)
END
CLS
INPUT "Enter any String : "; s$
PRINT "Total Number of Vowel 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" OR c$ = "E" OR c$ = "I" OR c$ = "O" OR c$ = "U" 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.