int main()
{
bool tof = false; //initializes tof bool to false
int vowels = 0;
char x;
cout << "Please enter a letter to see if it is a vowel" << endl << endl; // Asks the user to enter a letter
cin >> x;
tof = isVowel (x);
if (tof != 0){
}
system("PAUSE");
return 0;
}
bool isVowel(int num)
{
if ('A' == num || 'a' == num ||'E' == num || 'e' == num ||'I' == num ||'i' == num ||'O' == num || 'o' == num ||'U' == num || 'u' == num)
{
return true;
I think the main problem with your loop is...you don't have a loop.
Also...when checking the value of a bool it is better practice to either compare it to a bool value or just the actual bool itself. Remember a condition (something that you supply an if statement with) IS a bool, so just the bool would suffice:
You are also passing in a int to your function, when I'm pretty sure you meant to pass a char. Not that there's a real difference in the storage of it, there is in the functionality of it. And another tip; to avoid having to use both upper and lower case validation, you could just make use of the tolower() function:
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.