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
#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