Character is a vowel or consonant

#include <iostream>
using namespace std;
int main(){
    char ch;
    int lowerCase,upperCase;
    cout<<"Enter character"<<endl;
    cin>>ch;

    // evaluates to 1 if variable c is a lowercase vowel
    lowerCase = (ch == 'a' || ch == 'i' || ch == 'e' || ch == 'o' || ch == 'u');

    // evaluates to 1 if variable c is a UpperCase vowel
    upperCase = (ch == 'A' || ch == 'I' || ch == 'E' || ch == 'O' || ch == 'U');

    if(lowerCase || upperCase)
        cout<<ch<< " is Vowel"<<endl;
    else
        cout<<ch<<" is Consonant"<<endl;

    return 0;
}

    Leave a Reply

    Your email address will not be published.

    Need Help?