TO FIND NO OF VOWELS IN A STRING

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,len,w=1,c=0,v=0;
char s1[20],ch;
clrscr();
printf("\n \t \t Input:");
printf("\n \t \t _____:");
printf("\n \t \t Enter the text:");
gets(s1);
len=strlen(s1);
for (i=0;i<=len-1;i++)
{
 ch=s1[i];
 switch(ch)
 {
   case 'a':
   case 'e':
   case 'i':
   case 'o':
   case 'u':
     v++;
     break;
     case ' ':
     break;
     default:
     c++;
     }
}
if (s1[i]==' ' && s1[i-1]!=' ')
   {
   w++;
   }
printf("\n the number of vowels is %d",v);
getch();
}

No comments:

Related Posts with Thumbnails