Saturday, October 22, 2016

Qbasic Program: Count Vowel and Consonant



161. 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


162. 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

163.  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 SUB



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

164.  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

165.  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





166. 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

167.  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


168.  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

169. 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




170.  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




171. WAP to input any string and display only consonant by removing vowels.
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
W$=W$+B$
END IF
NEXT I
PRINT W$
END SUB

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

SUB DISP (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
W$=W$+B$
END IF
NEXT I
PRINT W$
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION DISP$ (S$)
CLS
INPUT "ENTER ANY STRING"; S$
PRINT DISP(S$)
END

FUNCTION DISP$ (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
W$=W$+B$
END IF
NEXT I
DISP$ =  W$
END FUNCTION

14 comments:

  1. WAP TO REMOVE THE SPACE FROM THE GIVEN SENTENCE?

    ReplyDelete
    Replies
    1. Qbasic Programming Solutions And Slc / See Computer Science Questions Solved : Qbasic Program: Count Vowel And Consonant >>>>> Download Now

      >>>>> Download Full

      Qbasic Programming Solutions And Slc / See Computer Science Questions Solved : Qbasic Program: Count Vowel And Consonant >>>>> Download LINK

      >>>>> Download Now

      Qbasic Programming Solutions And Slc / See Computer Science Questions Solved : Qbasic Program: Count Vowel And Consonant >>>>> Download Full

      >>>>> Download LINK C7

      Delete
  2. CLS
    INPUT "ENTER ANY STRING"; S$
    FOR I = 1 TO LEN(S$)
    B$ = MID$(S$, I, 1)
    C$ = UCASE$(B$)
    IF C$ <> " " THEN
    W$ = W$ + B$
    END IF
    NEXT I
    PRINT W$
    END

    ReplyDelete
  3. PROGRAM TO COUNT SPACE IN A SENTENCE.
    PLZ PROVIDE ME THE CODE

    ReplyDelete
  4. WAP to count letter R in the given sentence

    ReplyDelete
  5. Wap to display the vowels and consonants in any given string. (Not the total number of vowels & consonants)

    ReplyDelete

  6. Write a sub procedure to ask to enter a string then find out number of consonents

    ReplyDelete
  7. ) to display a new word from consonant characters from an entered word (

    ReplyDelete
  8. How to write the program to calculate the repetition of 'a' in a word?

    ReplyDelete
  9. Qbasic program to check the entered character is vowel or consonant using FUNCTION.... END FUNCTION
    PLZ reply me

    ReplyDelete
  10. WAP to input a string and print the total vowel

    ReplyDelete