Friday, October 1, 2021

WAP to input any string and count total no. of vowels.

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
      END IF
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
 
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


Using FUNCTION Procedure

DECLARE FUNCTION VowelCount(s$)
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

No comments:

Post a Comment

If you have any doubts, Please let me know.

[Download PDF] Computer Science Book Gread-10 in Nepali Language

 If you are searching for class 10 Computer Science in Nepali pdf for free download then you are at the right page. This book is soley publi...