C++ Program to Check Whether a Character is Vowel or Consonant.

Here is a C++ program to check whether an alphabet is vowel or consonant. To check whether a character is vowel or consonant, we will take a character as input from user using cin and store in char data type variable.

Then, we check whether it is any one of these ten characters(lower and upper case vowels) a, A, e, E, i, I, o, O, u and U using || operator. If input character is any one of these ten vowel characters, then it is a vowel otherwise a consonant.

English has five proper vowel letters (A, E, I, O, U) all alphabets except these characters are consonants.

C++ Program to check whether an alphabet is vowel or Consonant

#include <iostream>

using namespace std;

int main() {
    char c;
    cout << "Enter a Character\n";
    cin >> c;
    /* Check if input alphabet is member of set{A,E,I,O,U,a,e,i,o,u} */
    if(c == 'a' || c == 'e' || c =='i' || c=='o' || c=='u' || c=='A'
          || c=='E' || c=='I' || c=='O' || c=='U'){
        cout << c << " is VOWEL";
    } else {
        cout << c <<" is CONSONANT";
    }
    
    return 0;
}
Output
Enter a Character
R
R is CONSONANT
Enter a Character
E
E is VOWEL

Recommended Posts
C++ Program to Check Whether a Character is Vowel or Not
C++ Program to Check Whether a Character is Alphabet or Not
C++ Program to Check Whether Number is Even or Odd
C++ Program to Check Strings are Anagram or Not
C++ Program to check Whether a Number is Palindrome or Not
C++ Program to Generate Random Numbers
C++ Program to Find Factorial of a Number
C++ Program to Count Zeros, Positive and Negative Numbers
C++ Program to Calculate Average Percentage Marks
All C++ Programs