I've been banging my head against the wall for days now, trying to get this function to return a value. I think I'm too close, but I suspect that my isVowel function doesn't return anything. Could you take a look?
Thank you, thank you, thank you. I used this and put on some finishing touches to make the program useable multiple times. The result worked. Here it is.
#include <iostream>
#include <string>
usingnamespace std;
bool isVowel(char);
int main()
{
string line;
char end = 'y';
cout << "This program will observe a word or sentence and determine whether or" << endl;
cout << "not it contains vowels, and how many vowels it contains." << endl;
while (end != '#')
{
cout << "Please enter a word or sentence:" << endl;
cin.ignore();
getline(cin, line);
int counter = 0;
for (size_t i = 0; i < line.size(); i++)
{
if (isVowel(line[i]))
counter++;
}
cout << "This entry contains " << counter << " vowels." << endl;
cout << "If you would like to enter another word or phrase enter any key." << endl;
cout << "If you would like to terminate press #" << endl;
cin >> end;
}
return 0;
}
bool isVowel(char ch)
{
ch = tolower(ch);
if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
returntrue;
returnfalse;
}