Tuesday 13 December 2016

Write a program to calculate number of vowels (a, e, i, o, u) separately in the entered string.

/*   ###########################
     Girfa : Student Help
     for more program visit :http://girfahelp.blogspot.in/p/c-language.html
     Count no. of vowel seprately
     ############################
*/
#include<stdio.h>
#include<conio.h>
void main()
{
     char ch[200];
     int a,e,i,o,u,index;
     a=i=o=u=e=0;
     clrscr();
     printf("Enter your string>> ");
     gets(ch);
     for(index=0;ch[index]!='\0';index++)
     {
           switch(ch[index])
           {
                case 'a' :
                     a++;
                     break;
                case 'A' :

                     a++;
                     break;

                case 'e':
                     e++;
                     break;
                case 'E':
                     e++;
                     break;

                case 'o':
                     o++;
                     break;
                case 'O':
                     o++;
                     break;

                case 'i':
                     i++;
                     break;
                case 'I':
                     i++;
                     break;

                case 'u':
                     u++;
                     break;
                case 'U':
                     u++;
                     break;

           }
     }
     printf("\nVowel frequency\nA=%d\nE=%d\nI=%d\nO=%d\nU=%d",a,e,i,o,u);
     getch();


}

No comments:

Post a Comment