count vowel, consonant, word, sentences



223. WAP to input any string and count total no. of vowels.
CLS
INPUT "ENTER ANY STRING"; S$
VC = 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
END IF
NEXT I
PRINT "TOTAL NO. OF VOWELS= "; VC
END

USING SUB PROCEDURE

DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (S$)
VC = 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
END IF
NEXT I
PRINT "TOTAL NO. OF VOWELS= "; VC
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF VOWELS= "; COUNT(S$)
END

FUNCTION COUNT (S$)
VC = 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
END IF
NEXT I
COUNT = VC
END FUNCTION


224. WAP to input any string and display only vowels.
CLS
INPUT "ENTER ANY STRING"; S$
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
PRINT B$
END IF
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB DISPV (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL DISPV(S$)
END

SUB DISPV(S$)
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
PRINT B$
END IF
NEXT I
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION DISPV (S$)
CLS
INPUT "ENTER ANY STRING"; S$
VC = DISPV(S$)
END

FUNCTION DISPV(S$)
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
PRINT B$
END IF
NEXT I
END FUNCTION



225.  WAP to input any string and count total no. of consonants.
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 PROCEDURE

DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (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

USING FUNCTION PROCEDURE
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)
END

FUNCTION COUNT (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
COUNT = CC
END FUNCTION

226.  WAP to input any string and display only consonants.
CLS
INPUT "ENTER ANY STRING"; S$
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
PRINT B$
END IF
NEXT I
END

USING SUB PROCEDURE

DECLARE SUB DISPC (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL DISPC(S$)
END

SUB DISPC(S$)
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
PRINT B$
END IF
NEXT I
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION DISPC (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CC = DISPC(S$)
END

FUNCTION DISPC(S$)
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
PRINT B$
END IF
NEXT I
END FUNCTION

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

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
END

USING SUB PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (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
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)
END

FUNCTION COUNT (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="; CC
COUNT = CC
END FUNCTION

228. WAP to input any word and count total no. of vowels and consonants.
CLS
INPUT "ENTER ANY WORD"; S$
VC = 0
CC = 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
ELSE
CC = CC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF VOWELS= "; VC
PRINT "TOTAL NO. OF CONSONANTS="; CC
END

USING SUB PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY WORD"; S$
CALL COUNT(S$)
END

SUB COUNT (S$)
VC = 0
CC = 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
ELSE
CC = CC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF VOWELS= "; VC
PRINT "TOTAL NO. OF CONSONANTS="; CC
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY WORD"; S$
PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)
END

FUNCTION COUNT (S$)
VC = 0
CC = 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
ELSE
CC = CC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF VOWELS="; CC
COUNT = CC
END FUNCTION

229.  WAP to input any string and count total no. of words.

CLS
INPUT "ENTER ANY STRING"; S$
WC = 1
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
WC = WC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF WORDS= "; WC
END SUB


USING SUB PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (S$)
WC = 1
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
WC = WC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF WORDS= "; WC
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF WORDS= "; COUNT(S$)
END

FUNCTION COUNT (S$)
WC = 1
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
WC = WC + 1
END IF
NEXT I
COUNT = WC
END FUNCTION


230.  WAP to input any string and count total no. of vowels , consonants and words.
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 PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (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

USING FUNCTION PROCEDURE
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)
END

FUNCTION COUNT (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="; CC
PRINT "TOTAL NO. OF WORDS="; WC
COUNT = CC
END FUNCTION

231. WAP to input any string and count total no. of sentences.
CLS
INPUT "ENTER ANY STRING"; S$
SC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
SC = SC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF SENTENCES= "; SC
END SUB


USING SUB PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (S$)
SC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
SC = SC + 1
END IF
NEXT I
PRINT "TOTAL NO. OF SENTENCES= "; SC
END SUB

USING FUNCTION PROCEDURE

DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF SENTENCES= "; COUNT(S$)
END

FUNCTION COUNT (S$)
SC = 0
FOR I = 1 TO LEN(S$)
B$ = MID$(S$, I, 1)
IF B$ = " " THEN
SC = SC + 1
END IF
NEXT I
COUNT = SC
END FUNCTION




232.  WAP to input any string and count total no. of vowels , consonants, words and sentences.
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
PRINT "TOTAL NO. OF SENTENCES="; SC
END

USING SUB PROCEDURE
DECLARE SUB COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
CALL COUNT(S$)
END

SUB COUNT (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
PRINT "TOTAL NO. OF SENTENCES="; SC
END SUB

USING FUNCTION PROCEDURE
DECLARE FUNCTION COUNT (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)
END

FUNCTION COUNT (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="; CC
PRINT "TOTAL NO. OF WORDS="; WC
PRINT "TOTAL NO. OF SENTENCES="; SC
COUNT = CC
END FUNCTION

Comments

Unknown said…
The programs done by function procedure is wrong

Popular posts from this blog

PROGRAM TO FIND SQUARE, CUBE, SQUARE ROOT AND CUBE ROOT OF GIVEN NUMBER

PROGRAM TO DISPLAY SUM, PRODUCT, DIFFERENCE AND PRODUCT OF TWO / THREE NUMBERS

PALINDROME AND ARMSTRONG PROGRAMS