There are five vowel characters {a, e, i, o, u}. If the user given character input is one of them that means it is a vowel otherwise it is a consonant.
Logic
Here we have to manually check the given character with all the vowel characters, we cannot use ASCII value range to determine whether it is a vowel or a consonant. The given character can also be in the form of uppercase.
Program
#include <iostream> using namespace std; int main() { char c; cout << "Enter a alphabet : "; cin >> c; // if given character is Lower case Vowel or Upper case Vowel // then print vowel otherwise consonant if ((c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') || (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U')) { cout << endl << c << " is a vowel."; } else{ cout << endl << c << " is a consonant."; } return 0; }
Output
Enter a alphabet : A
A is a vowel.