write a program in java to take a proverbial statement (like the failures are the pillar of success) as an input and print the frequency of vowels in it
Answers
Answered by
3
void main()
{
int a=0,e=0,i=0,o=0,u=0,sum=0;
char c;
printf("Enter string:- ");
printf("\nString will be terminated if you press Ctrl-Z & then ENTER.");
printf("\nSTRING:- ");
while ((c=getchar())!=EOF)
{
if (c=='a'||c=='A')
a=a+1;
if (c=='e'||c=='E')
e=e+1;
if (c=='i'||c=='I')
i=i+1;
if (c=='o'||c=='O')
o=o+1;
if (c=='u'||c=='U')
u=u+1;
}
sum=a+e+i+o+u;
printf("\nFrequency of vowel 'a' is %d.",a);
printf("\nFrequency of vowel 'e' is %d.",e);
printf("\nFrequency of vowel 'i' is %d.",i);
printf("\nFrequency of vowel 'o' is %d.",o);
printf("\nFrequency of vowel 'u' is %d.",u);
printf("\nTotal no. of vowels in the text is %d.",sum);
}
/*
{
int a=0,e=0,i=0,o=0,u=0,sum=0;
char c;
printf("Enter string:- ");
printf("\nString will be terminated if you press Ctrl-Z & then ENTER.");
printf("\nSTRING:- ");
while ((c=getchar())!=EOF)
{
if (c=='a'||c=='A')
a=a+1;
if (c=='e'||c=='E')
e=e+1;
if (c=='i'||c=='I')
i=i+1;
if (c=='o'||c=='O')
o=o+1;
if (c=='u'||c=='U')
u=u+1;
}
sum=a+e+i+o+u;
printf("\nFrequency of vowel 'a' is %d.",a);
printf("\nFrequency of vowel 'e' is %d.",e);
printf("\nFrequency of vowel 'i' is %d.",i);
printf("\nFrequency of vowel 'o' is %d.",o);
printf("\nFrequency of vowel 'u' is %d.",u);
printf("\nTotal no. of vowels in the text is %d.",sum);
}
/*
Similar questions