C++ Program to Check Whether a Character is Vowel or Not

  • C++ Program to Check Whether a Character is Vowel or Not using if else statement

In this C++ program, to check whether a character is vowel or not we will compare the given character with uppercase and lowercase vowel alphabets.

There are five proper vowel letters (A, E, I, O, U) in English alphabets and all alphabets except vowels are called consonants. We have to whether given character is member of following set.

Vowels : {A, E, I, O, U, a, e, i, o, u};

C Program to Check a Character is Vowel or not

//C++ Program to check whether an alphabet is vowel or Consonant
//Vowels: {A,E,I,O,U}

#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 a Vowel\n";
    } else {
        cout << c <<" is a Consonant\n";

    return 0;
Enter a character
U is a Vowel
Enter a character
Z is a Consonant

In above program, we first take a character input form user and store it in a char variable c. Then we compare c with each uppercase and lowercase vowel character. If c matches with any vowel alphabet then we print a message on screen saying "c is a Vowel" otherwise we print "c is not a Consonant"