-
Help! I'm still learning
Alright, so the assignment for my entry level c++ class is to write a function isVowel in a program that can identify whether a letter entered by a user is a vowel or not. Here is what I have conjured up however know from looking at it I am very wrong in my approach, can somebody out there send me in the right direction, I cannot figure it out from my text and tutorials. Thanks for your input!
Code:
#include <iostream>
using namespace std;
char isVowel(char ch);
int main()
{
char ch;
cout << "Please enter a letter from the alphabet: ";
cin >> ch;
cout<<"the letter you have entered is: isVowel(ch)";
return 0;
}
char isVowel(char x)
{
if (char ch = 'a')
cout << "A Vowel" <<endl;
else
cout << "Not a vowel" <<endl;
return 1;
}
-
See my post to this in GD. Ignore a and b, though, and try to avoid cross posting.
One other thing, make sure that your call to isVowel is not enclosed in quotes.
Cheers
-
> cout<<"the letter you have entered is: isVowel(ch)";
Perhaps
cout<<"the letter you have entered is: " << isVowel(ch);
-
Pseudo boolean is_val() function:
Code:
bool class::is_val(possibly pass in your string here)
{
1) toupper(string) //from the <cctype> library
2) create a loop... perhaps a 'while' loop or a 'for' loop with strnglen( ) as a parameter
3) make a character-by-character == comparison
4) return true when string[i] == ('A' || 'E' || 'I' || 'O' || 'U')
5) else return false
}
Hope this helps ;)
-
And just so everything in that thread is in this thread...
should be
Code:
if (char ch == 'a')