175k views
2 votes
Write a c++ program that reads a word and prints the number of syllables in the word. For this exercise, assume that syllables are determined as follows: Each sequence of vowels a e i o u y, except for the last e in a word, is a vowel. However, if that algorithm yields a count of 0, change it to 1. For example, Word Syllables

Harry 2
hairy 2
hare 1
the 1

User Wibbly
by
6.9k points

1 Answer

7 votes

Answer:

Step-by-step explanation:

#include "stdafx.h"

#include <iostream>

#include <string>

using namespace std;

int main()

{

char word;

int count = 0;

cout << "Please enter the word from which you want to check syllables: ";

cin.get(word);

cout << "Vowels: ";

while (word !=)<<endl;

{

cin.get(word);

switch (toupper(word))

{

case 'A': cout << word << ", ";

count++;

break;

case 'I': cout << word << ", ";

count++;

break;

case 'O': cout << word << ", ";

count++;

break;

case 'U': cout << word << ", ";

count++;

break;

case 'Y': cout << word << ", ";

count++;

break;

}

}

if (cin.get(word))

{

word == 'AI';

word == 'AU';

word == 'EA';

word == 'EE';

word == 'IE';

word == 'OA';

word == 'EO';

word == 'OI';

word == 'OO';

word == 'OU';

word == 'UI';

count--;

}

cout << "total number of " << count << " syllables in your word are:" << endl;

return 0;

}

User Monzonj
by
6.8k points