#include<stdio.h>
#include<conio.h>
main()
{
char a[50];
int i,vowels=0, consonants=0,space=0;
printf(“Enter a sentence:”);
gets(a);
for(i=0;a[i]!=’\0’;i++)
{
if(a[i]==’a’ || a[i]==’e’ || a[i]==’i’ || a[i]==’o’ || a[i]==’u’ || a[i]==’A’ || a[i]==’E’ || a[i]==’I’ || a[i]==’O’ || a[i]==’U’ )
{
vowels++;
}
else
{
consonants++;
}
if(a[i]==’ ’)
{
space++;
}
}
consonants=consonants-space;
printf(“No of vowels in given sentence = %d”,vowels);
printf(“No of consonants in given sentence = %d”,consonants);
getch();
}
Output:
Enter a sentence: I love my India
No of vowels in given sentence = 6
No of consonants in given sentence = 6