Friday, November 23, 2012

INPUT A STRING AND FIND THE NUMBER OF TIMES, EACH OF THE FIVE VOWELS APPEAR IN THE GIVEN STRING


/*    INPUT A STRING AND FIND THE NUMBER OF TIMES, EACH OF THE FIVE
     VOWELS APPEAR IN THE GIVEN STRING
*/
#include<stdio.h>
#include<conio.h>
#include<string.h>

#define MAX 50

void main()
{
            char str[MAX];
            int a=0,e=0,i=0,o=0,u=0,loop;
            clrscr();
            printf("Enter a string : ");
            gets(str);
            for(loop=0;loop<strlen(str);loop++)
            {
                        switch(str[loop])
                        {
                                    case 'a':
                                    case 'A': a++; break;
                                    case 'e':
                                    case 'E': e++; break;
                                    case 'i':
                                    case 'I': i++; break;
                                    case 'o':
                                    case 'O': o++; break;
                                    case 'u':
                                    case 'U': u++; break;
                        }
            }
            printf("\n The number of a's in the string : %d ",a);
            printf("\n The number of e's in the string : %d ",e);
            printf("\n The number of i's in the string : %d ",i);
            printf("\n The number of o's in the string : %d ",o);
            printf("\n The number of u's in the string : %d ",u);
            getch();
}
/*
            =====OUT PUT=====

            Enter a string : BHARATH AND KAUNDINYA did programing.

             The number of a's in the string : 6
             The number of e's in the string : 0
             The number of i's in the string : 3
             The number of o's in the string : 1
             The number of u's in the string : 1

*/

0 comments:

Post a Comment