Program to find if a character is vowel or Consonant in C++


In this tutorial, we will be discussing a program to find if a character is a vowel or consonant.

For this, we will be provided with a character. Our task is to print out to the user whether the provided character is a vowel or a consonant.

Example

 Live Demo

#include <iostream>
using namespace std;
//checking if the character is a vowel or consonant
void is_vowel(char x){
   if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u')
      cout << "Vowel" << endl;
   else
      cout << "Consonant" << endl;
}
int main(){
   is_vowel('c');
   is_vowel('e');
   return 0;
}

Output

Consonant
Vowel

Updated on: 04-May-2020

144 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements