Can Someone help me to Create a program that receives a character and returns true if a character is a VOWEL and false otherwise.

Recommended Answers

All 5 Replies

Show us your program . We'll help you. But for the basic idea , use an if else statement .

This may get you started ...

// function to return true if char c 
// passed in is a vowel ...
// otherwise to return false
bool isVowel( char c )
{
    c = toupper(c);
    if( c == A' || c == 'E' || c == 'I' || 
        c =='O' || c == 'U' )
       return true;
     // else ...
    return false;
}

//int main()
//{
//   prompt for input ...
//   char c = cin.get();
//   if( isVowel( c ) ) cout << c << " is a vowel.";
//   else cout << c << " is NOT a vowel.";
//}

switch statement would be better for it. And consider both uppercase and lowercase letters.

You could try this:

void Vowel(char c)
{
int k = c; // to diplay the right letter
c = tolower(c); // to avoid the verification of both types of letter
if (c == 'a' || c == 'e' || c == 'i' || c == 'i' || c == 'u')
    cout<<k<<" is vowel!";
else cout<<k<<" is not a vowel!";
}

int main()
{
int c;
cin>>c;
Vowel(c);
return 0;
}

Guys ... You dont give the entire program to someone . Let him show his code. Then help him solve it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.