Question: write a program that reads an unknown number of words strings that are only lowercase letters stopping when the word quit is entered. None of

write a program that reads an unknown number of words strings that are only lowercase letters stopping when the word quit is entered. None of your strings will ever have more than 20 characters. The program counts the number of times that each vowel is seen, and prints the total number of occurrences of each vowel at the end.

My code

#include

void main(void) { char sentence[100]; int i = 0; int counta = 0; int counte = 0; int counti = 0; int counto = 0; int countu = 0;

printf("Enter a sentence "); scanf("%s", sentence);

for (i = 0;((sentence[i] != 'q')&&(sentence[i+1] != 'u')&&(sentence[i+2] != 'i')&&(sentence[i+3] != 't')); i++) { if (sentence[i] == 'a') { counta ++; } else if (sentence[i] == 'e'){

counte++; } else if (sentence[i] == 'i'){

counti++; } else if (sentence[i] == 'o'){

counto++; } else if (sentence[i] == 'u'){

countu++; } else if (sentence[i] == ' '){ continue; } }

printf("The vowel a occurred %d times ", counta); printf("The vowel e occurred %d times ", counte); printf("The vowel i occurred %d times ", counti); printf("The vowel o occurred %d times ", counto); printf("The vowel u occurred %d times ", countu); 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!