A Program to Check Whether a Character is Vowel or Consonant
In this example, we are giving a program which is useful to check whether a character given by the user is vowel or consonant.
Program to check Vowel or Consonant:
#include <iostream>using namespace std;int main(){char c;int isLowercaseVowel, isUppercaseVowel;cout << "Enter an alphabet: ";cin >> c;// true if c is a lowercase vowelisLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');// true if c is an uppercase vowelisUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');// true if either isLowercaseVowel or isUppercaseVowel is trueif (isLowercaseVowel || isUppercaseVowel)cout << c << " is a vowel.";elsecout<< c << " is a consonant.";return 0;}
Output:
Enter an alphabet: E E is a vowel.