Question: You will write a program that reads in a line of text and generates a histogram of the vowels (a,e,i,o,u) that occur in the text.

You will write a program that reads in a line of text and generates a histogram of the vowels (a,e,i,o,u) that occur in the text. This is the code I have so far, but I need help invoking the main method and also, making sure that the line of text entered is NOT hardcoded, but rather, allows for the user to enter random input via the terminal! I would appreciate any help I could get on fixing this code. Thanks!

#include

#include

#define LEN 256

int isAVowel(char str);

void vowelCount(char str[]);

//function that returns 1 if is a vowel and 0 if not

int isAVowel(char phrase) {

char array[]= {'a','e','i','o','u'};

int size = 6;

for(int i = 0; i < strlen(str); i++) {

if(str == array[i])return 1;

}

return 0;

}

void vowelCount(char str[]) {

int aCount = 0,eCount = 0,iCount = 0,oCount = 0,uCount = 0;

for(int i=0; i

//ensure output is case-insensitive and increases //counts for each vowel given the input

if(str[i]=='a' || str[i]=='A')

aCount++;

else if(str[i]=='e' || str[i]=='E') {

eCount++;

}

else if(str[i]=='i' || str[i]=='I') {

iCount++;

}

else if(str[i]=='o' || str[i]=='O') {

oCount++;

}

else if(str[i]=='u' || str[i]=='U'){

uCount++;

}

}

printf("a: ");

for(int i = 0; i < aCount; i++) {

printf("* ");

}

printf(" e: ");

for(int i = 0; i < eCount; i++) {

printf("* ");

}

printf(" i: ");

for(int i = 0; i < iCount; i++) {

printf("* ");

}

printf(" o: ");

for(int i = 0; i < oCount; i++) {

printf("* ");

}

printf(" u: ");

for(int i = 0; i < uCount; i++){

printf("* ");

}

printf(" ");

}

int main () {

printf("Enter a phrase: ");

char str[127];

char phrase;vowelCount(str);

for (i = 0; i < strlen(phrase); i++) {

if(isAVowel(str[i]) == 0)

printf("%c", str[i]); }printf(" "); return 0;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!