Write a program in C language to prints frequency of vowels and the total count of consonants.
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
char s[100],ch;
int i,vc=0,cc=0;
clrscr();
printf("Enter the sentence\n");
gets(s);
for(i=0;i<strlen(s);i++)
{
if(isalpha(s[i]))
{
ch=tolower(s[i]);
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
vc++;
else
cc++;
}
}
printf("No of vowels=%d\n",vc);
printf("No of consonants=%d",cc);
getch();
}
Output:
Enter the sentence
Welcome to Chandigarh
No of vowels=7
No of consonants=12
Post A Comment:
0 comments: