Question: I am working on creating this program from the screenshot in Visual Studio and am receiving two errors. Both are related to the else line.

I am working on creating this program from the screenshot in Visual Studio and am receiving two errors. Both are related to the "else" line. One error says "expected a statement" and the other says "illegal else without matching if". Please help me to not only fix the errors but make sure the program is executed properly and gives the correct output. Also I'm only familiar with Visual Studio and using namespace std so please use these only.
Following is my code:
// ConsoleApplication15.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);
}
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))
{
count++;
}
{
prev_letter_vowel = true;
}
else
{
// currentLetter is not a vowel
prev_letter_vowel = false;
}
if (count == 0)
{
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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
