Counting vowels in the given string using User Defined Functions

DECLARE FUNCTION countvow(s$)
CLS
INPUT "Enter testing string=";v$
PRINT "Number of vowels=";countvow(v$)
END

FUNCTION countvow(s$)
FOR i=1 TO LEN(s$)
  ch$=LCASE$(MID$(s$, i, 1))
  SELECT CASE ch$
  CASE "a", "e", "i", "o", "u"
     cnt=cnt+1
  END SELECT
NEXT i
countvow=cnt
END FUNCTION

33 comments:

  1. Please Help me.
    WAP in qbasic to supply a sentences and count the number of consonants in the sentences.. Please help

    ReplyDelete
    Replies
    1. CLS
      FOR I=1 TO LEN (S$)
      A$= UCASE$(MID $(S$,I,1))
      SELECT CASE A$
      CASE "B","C","D","F","G","H","J","K","L","M","N","P","Q","R","S","T","V","W", "X","Y","Z"
      C=C+1
      END SELECT
      NEXT I
      PRINT "NUMBER OF CONSONANTS"; C
      END

      Delete
    2. cls
      for i = 1 to len(a$)
      b$=mid$(a$,i,1)
      if b$="a" or b$="e" or b$="o" or b$="i" or b$="u" then
      x=0
      else
      c=c+1
      end if
      end

      Delete
    3. There still an error in the code

      Delete
    4. Not required x=0
      After the if condition write next i
      Print c
      End

      Delete
  2. please solve the prigram to accept and display by changing its case e.g. kAthMANdU into KaTHmanDu

    ReplyDelete
    Replies
    1. CLS
      INPUT "ENTER A WORD IN RANDOM CASE";W$
      FOR I = 1 TO LEN(W$)
      A$ = UCASE$(MID$(W$,I,1))
      B$ = LCASE$(MID$(W$,I,1))
      IF MID$(W$,I,1) = A$ THEN
      PRINT B$
      ELSE
      PRINT A$
      END IF
      NEXT I
      END

      Delete
    2. CLS
      INPUT "ENTER A WORD IN RANDOM CASE";W$
      FOR I = 1 TO LEN(W$)
      A$ = UCASE$(MID$(W$,I,1))
      B$ = LCASE$(MID$(W$,I,1))
      IF MID$(W$,I,1) = A$ THEN
      PRINT B$
      ELSE
      PRINT A$
      END IF
      NEXT I
      END

      Delete
  3. WAP to input a string and display the vowel characters from it in qbasic

    ReplyDelete
    Replies
    1. CLS
      INPUT"ENTER ANY STRING";A$
      R$=LCASE$(A$)
      FOR I= 1 TO LEN(A$)
      T$=MID$(R$,I,1)
      IF T$="A" OR T$="E" OR T$="I" OR T$="O" OR T$="U" THEN
      C$=T$+R$
      END IF
      NEXT I
      PRINT C
      END

      Delete
  4. WAP TO PRINT A SENTENCE WITHOUT VOWELS

    ReplyDelete
  5. help me please:
    WAP for counting vowels and number of words existing in entered line of text

    ReplyDelete
  6. please help me how to find number of words in a sentence

    ReplyDelete
    Replies
    1. DECLARE FUNCTION COUNT(S$)
      CLS
      INPUT"ENTER ANY STRING";S$
      PRINT"NO. OF WORD IS=";COUNT(S$)
      END

      Delete
  7. Wap to find frequency of VOWELS in a word in u case
    SAMPLE INPUT:METEOR
    SAMPLE OUTPUT:FREQUENCY OF A= 0
    E= 2
    I=0
    O = 1
    U =0

    ReplyDelete
  8. sir please solve this problem that to display the total number of character from the input given by the user without using LEN function...

    ReplyDelete
  9. sir please solve this problem that to accept 54, 67, 98,12, 34,87,98,23 (like this nimber) and display the sum of this number

    ReplyDelete
  10. Sir please show a program to extract all vowels and replace them with 0

    ReplyDelete
  11. please reverse the sentence
    like :- old is gold.
    output should be :- gold is old.

    ReplyDelete
    Replies
    1. CLS
      F$ = "oldisgold"
      G$ = MID$(F$, 6, 4)
      H$ = MID$(F$, 4, 2)
      I$ = MID$(F$, 1, 3)
      n$ = n$ + G$ + H$ + I$
      PRINT n$;
      END

      Delete
    2. This comment has been removed by the author.

      Delete
  12. WAP in qbasic to display all the vowels preset in lower case alphabets

    ReplyDelete
  13. Write a program to display the total number of vowels in the given words:
    Information and Generation
    Plz help

    ReplyDelete
  14. Write a program to add two strings and add them
    Please help me

    ReplyDelete
  15. This is to print
    *nepal*
    **nepal**
    ***nepal***
    ****nepal****
    *****nepal*****
    CLS
    a$ = "nepal"
    b$ = "*****"
    s = 5
    FOR k = 1 TO 5
    c$ = LEFT$(b$, k)
    PRINT TAB(s); c$ + a$ + c$
    s = s - 1
    NEXT k
    END

    ReplyDelete
    Replies
    1. question
      *nepal*
      **nepal**
      ***nepal***
      ****nepal****
      *****nepal*****

      Delete
  16. Wap to input any string and count the total numbers of "R" characters in that string

    ReplyDelete
  17. Can sny one give any other idea about this program Using function

    ReplyDelete
  18. Plzzz help me qbasic: input a string and then print all the vowel letters from the string

    ReplyDelete
  19. How to count the number of uppercase letters in a string

    ReplyDelete
  20. Plz help me
    WAP that accepts a word from the user and displays how many times letter 'a' is repeated in a word
    Plz help....

    ReplyDelete