1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FUNCTION problem.

Discussion in 'C' started by singh_r85, May 27, 2010.

  1. singh_r85

    singh_r85 New Member

    Joined:
    May 25, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    Write a function which accepts a string as a parameter and returns the number of vowels in the string.
     
  2. pkbis28

    pkbis28 New Member

    Joined:
    May 25, 2010
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    int getVowles(char *str) { int j=0,i=0; for(i=0;str!='\0\;i++) { switch(str) { case 'a': case 'A': case 'e': case 'E': case 'I': case 'i': case 'o': case 'O': case 'u': case 'u':j++; break; } } return j; }
     
  3. spoddar66

    spoddar66 New Member

    Joined:
    May 25, 2010
    Messages:
    23
    Likes Received:
    0
    Trophy Points:
    0
    Try this:
    int count_vowel(char str[]) { char str1[20]; int i,flag=0; strcpy(str1,str); for(i=0;str1;i++) { if((str1=='a')||(str1=='e')||(str1=='o')||(str1=='u')) flag++ } return flag; }
     
  4. pkbis28

    pkbis28 New Member

    Joined:
    May 25, 2010
    Messages:
    24
    Likes Received:
    0
    Trophy Points:
    0
    This will run :

    count_vowel(word) char word[50] { char ch; int v=0,i=0; while ((ch=word)!='\0') { switch(ch) { case 'a': case 'e': case 'i': case 'o': case 'u': v++; } i++; } return(v); }
     
  5. singh_r85

    singh_r85 New Member

    Joined:
    May 25, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    this didnot run.please help.
     

Share This Page