Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

compiler error help

Victoria TibbsVictoria Tibbs Member Posts: 2

im trying to write a program that counts the total vowels in a string and count the number of each individual vowel(like total A's=4 and so on) Im stuck with my fisrt function to count the total vowels im getting a compiler error that says expected primary expression before '}' token.I cant figure out what that means can someone help
`

             #include <stdio.h>

        int countvowels(char []);
       //int displayleachvowels(char[]);


     int main ()
      {
        char sentence[150];
        int vowels=0;


           printf("Enter a sentence \n");

           gets(sentence);

           vowels = countvowels(sentence);

           printf("Number of vowels: %d\n", sentence);

          // total=displayleachvowels(sentence);

          // printf("Total A's:,E's,I'sO's,U's, %d\n%d\n%d\n%d\n%d\n", sentence);

     return 0;
   }
   int countvowels(char sentence[])
 {
   int x;
   int count=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')    


     }//error pointing here

    count++;    


 }`
Tagged:

Comments

  • B00B00 Member Posts: 106 ✭✭✭

    Your if statement on lines 35-38 is unfinished. Add at least {} a the end of it for compiler to be happy.

Sign In or Register to comment.