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
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: