0

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

5
Contributors
5
Replies
24
Views
3 Years
Discussion Span
Last Post by Avishek_1
0

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

Edited by Avishek_1

1

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.";
//}
0

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

0

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;
}

Edited by BogdanCov: gramatic :( again

1

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.