im trying to write a c program that asks a user for a string and send it to a function
that counts the total number each of vowel and total number of all vowels but i am getting 0's for all can someone tell me why?

#include <stdio.h>

 int countvowels(char[]);
 int displayleachvowel(char[]);
int main()

{

   char sentence[150];

    int x, vowels = 0,eachvowel= 0;

    printf("Enter a sentence \n");

    gets(sentence);
    vowels = countvowels(sentence);
    eachvowel = displayleachvowel(sentence);
     printf("No. of vowels in %s = %d\n", sentence, vowels);
    printf("Total A's in %s =%d",sentence,eachvowel);
    printf("Total E's in %s =%d",sentence,eachvowel);
    printf("Total I's in %s =%d",sentence,eachvowel);
    printf("Total O's in %s =%d",sentence,eachvowel);
    printf("Total U's in %s =%d",sentence,eachvowel);
    return 0;
}
int countvowels(char sentence[])
{

  int x;
  int vowels = 0;

  for (x = 0; sentence[x] != '\0'; x++)     

  {

    if ((sentence[x] == 'a' || sentence[x] == 'e' || sentence[x] ==

        'i' || sentence[x] == 'o' || sentence[x] == 'u') ||

        (sentence[x] == 'A' || sentence[x] == 'E' || sentence[x] ==

        'I' || sentence[x] == 'O' || sentence[x] == 'U'))

    vowels++;

     return vowels;
  }
}

         int displayleachvowel(char sentence[])
   { 

      int x;    
      int eachvowel= 0; 
        for (x = 0; sentence[x] != '\0'; x++) 
     {

        if (sentence[x]=='a'||sentence[x]=='A')
        eachvowel++;

            if (sentence[x]=='e'||sentence[x]=='E')
            eachvowel++;

               if (sentence[x]=='i'||sentence[x]=='I')
               eachvowel++;

                 if (sentence[x]=='o'||sentence[x]=='O')
                 eachvowel++;

                  if (sentence[x]=='u'||sentence[x]=='U')
                eachvowel++;

     }

}

Your function displayleachvowel has no return statement.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.