- To print whether an alphabet is Vowel or Consonant
User Input: z
Output: It's a consonant
#include <iostream>
using namespace std;
int main() {
char c;
cout<<"Enter your character : ";
cin>>c;
if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
cout<<"It's a vowel";
else
cout<<"It's a consonant";
return 0;
}
Enter your character : E It's a vowelProgram
You should know first :
Vowel alphabets: a, e, i, o, u
Consonant alphabets: Alphabets other than vowels
//Check for vowels both in uppercase & lowercase
if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U') {
//if true print vowel
}
else {
//if false print consonant
}
Concept