to input any alphabet and check whether it is vowel or consonant.
#include <iostream>
using namespace std;
int main() {
char alpha;
bool lowercasevowel, uppercasevowel;
cout << "Enter an alphabet: ";
cin >> alpha;
lowercasevowel= (alpha == 'a' || alpha == 'e' || alpha == 'i' || alpha == 'o' || alpha == 'u');
uppercasevowel= (alpha == 'A' || alpha == 'E' || alpha == 'I' || alpha == 'O' || alpha == 'U');
if (!isalpha(alpha))
printf("wrong input");
else if (lowercasevowel || uppercasevowel)
cout << alpha << " is a vowel.";
else
cout << alpha << " is a consonant.";
return 0;
}
0 Comments
Post a Comment