description: This is C++ program to Check Whether a character is Vowel or Consonant.
code:
code:
/* C++ Program to Check Whether a character is Vowel or Consonant. */
#include <iostream>
using namespace std;
int main()
{
char ch;
int LowerCase, UpperCase;
cout << "Enter an character: ";
cin >> ch;
// if ch is match lower case vowel then LowerCase store 1
LowerCase = (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
// if ch is match Upper case vowel then LowerCase store 1
UpperCase = (ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U');
// Either LowerCase and UpperCase is become true(means 1) then prin is vowel
if (LowerCase || UpperCase)
cout << ch << " is a vowel.";
else
cout << ch << " is a consonant.";
return 0;
}
output:
Enter an character: j j is a consonant.