I have this code that I am having trouble trying to get working, I am new to programming and am having difficulty can someone help me get my function to work properly?
I have to identify whether or not a vowel has been entered then once it has been entered I need to display the number of vowels in the sentence. I can't figure out the proper logic to do the count and display my output. I am following my chapter but I am obviously doing something very wrong. The comments were what my teacher said needed to be done. Can someone help me?
#include <iostream>
using namespace std;
bool isVowel(char ch);
int main()
{
char letter, quit;
cout<<"Enter a sentence "<<endl;
cin.get(letter); // use cin.get(letter); to store the character data in variable ch
cout<<"There are "<<isVowel(letter)<<" vowels in this sentence. "<<endl;
cout<<"Press any key to continue "<<endl;
cin>>quit;
// use cin.get(ch); to store the character data in variable ch
return 0;
}
// add logic here to test if the character is a vowel
// and if it is a vowel,then increment a counter
bool isVowel(char ch)
{
if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' ||
ch == 'I' || ch == 'o' || ch == 'O' || ch == 'u' || ch == 'U')
{
return true;
}
else
{
return false;
}
}