Question: I wrote a program in Visual Studio using namespace std that calculates how many syllables are in a word but am unsure how to make


I wrote a program in Visual Studio using namespace std that calculates how many syllables are in a word but am unsure how to make the results appear in columns as shown in the photo. Please show me how this is done.
Following is my code:
// ConsoleApplication17.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
#include
#include
using namespace std;
int main()
{
string word;
cout
cin >> word;
int count = 0;
int i = 0;
char currentLetter = word[i];
bool prev_letter_vowel = false;
for (int i = 0; i
{
char currentLetter = word[i];
currentLetter = tolower(currentLetter); /* makes sure the vowels are lower case*/
}
/* for loop to count the syllables in the word with if-else block */
for (int i = 0; i
{
currentLetter = word[i];
if (currentLetter == 'a' || currentLetter == 'e' || currentLetter == 'i' || currentLetter == 'o'
|| currentLetter == 'u' || currentLetter == 'y') /* currentLetter is a vowel */
{
if (!prev_letter_vowel && !(currentLetter == 'e' && i == word.length() - 1)) /* if current letter is a vowel, previous one was not and the current letter is not an e and is not the last letter in the word then the vowel is counted as a syllable */
{
count++;
prev_letter_vowel = true;
}
}
else
{
/*currentLetter is not a vowel and is not counted as a syllable */
prev_letter_vowel = false;
}
}
if (count == 0) /* if no syllables are counted then the 0 is changed to 1 */
{
count = 1;
}
cout
system("pause");
return 0;
}
P4.14 Write a 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 algo- rithm yields a count of 0, change it to 1. For example, Word Syllables Harry hairy hare the 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
