Program in C to count number of vowels

Write a program in C to count number of vowels

#include <stdio.h>

void main ()
{
            char s[20],vw=0,i;
            clrscr();
            printf ("Enter any string: ");
            gets (s);
            for (i=0;i<=strlen(s);i++)
            {
                        switch (s[i])
                        {
                                    case 'a':
                                    case 'e':
                                    case 'i':
                                    case 'o':
                                    case 'u':
                                    case 'A':
                                    case 'E':
                                    case 'I':
                                    case 'O':
                                    case 'U':
                                    vw++;
                        }
            }
            printf ("There are %d vowels in it",vw);
            getch ();
}


Post a Comment