Write a Program to Check Whether a Character is a Vowel or Consonant

C++// C++ Program to print whether a character is vowel or not #include <cctype> #include <iostream> using namespace std; int main() { char ch = 'e'; if (isalpha(ch)) { if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U') { cout << ch << " is a vowel." << endl; } else { cout << ch << " is a consonant." << endl; } } else { cout << ch << " is not an alphabet." << endl; } return 0; }

Output

e is a vowel.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *