C programming problem Write a program vowelsc which counts t
C programming problem:
Write a program vowels.c which counts the number of times each of the vowels occurs in a file. The vowels are the characters a, e, i, o, and u. The program does not distinguish between upper and lower case characters. After counting the number of times each vowel occurs the program prints a “sideways” histogram of its results to an output file vowelsout.txt. For example, if an input file contains 48 a’s, 49 e’s, 48 i’s, 42 o’s, and 18 u’s, then the following should appear in the output file:
a: 48: ************************************************
e: 49: *************************************************
i: 48: ************************************************
o: 42: ******************************************
u: 17: *****************
/// Here is vowelsin.txt
But we refuse to believe that the bank of justice is bankrupt. We refuse to
believe that there are insufficient funds in the great vaults of opportunity
of this nation. And so, we\'ve come to cash this check, a check that will give
us upon demand the riches of freedom and the security of justice. I have a
dream that one day this nation will rise up and live out the true meaning of
its creed: \"We hold these truths to be self-evident, that all men are created
equal.\"
Solution
#include <stdio.h>
#include<conio.h>
void main()
{
char sentence[80];
int a=0,e=0,i=0,0,u=0;
int i,
clrscr();
printf(\"Enter a sentence \ \");
gets(sentence);
for (i = 0; sentence[i] != \'\\0\'; i++)
{
if (sentence[i] == \'a\' || sentence[i] == \'A\')
a++;
else if(sentence[i] == \'e\' || sentence[i] == \'E\')
e++;
else if(sentence[i] == \'i\') ||sentence[i] == \'I\')
i++;
else if( sentence[i] == \'o\' || sentence[i] ==\'O\')
o++;
else if( sentence[i] == \'u\' || sentence[i] == \'U\')
u++;
}
printf(\"a : %d\",a);
printf(\"e: %d\",e);
printf(\"i:%d\",i);
printf(\"o :%d\",o);
printf(\"u:%d\",u);
getch();
return 0;
}
