Write a program that determines if the input letter is a VOWEL or CONSONANT. The vowels are A E I O U while the consonants are the remaining letters of the alphabet. Your program must be able to handle a capital or small input letter.
#include <iostream>
using namespace std;
int main()
{
char c;
bool isLower, isUpper;
cout << "Enter a Character to check: ";
cin >> c;
// checks if input is a lowercase vowel
isLower = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
// checks if input is an uppercase vowel
isUpper = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
// print if the value of either isLower or isUpper is true, then the value is either a lowercase vowel or uppercase vowel
cout << "You entered: " << c << "\n";
if (isUpper || isLower)
cout << c << " - a vowel!";
else
cout << c << " - a consonant!!";
return 0;
}
Comments
Leave a comment