Answer to Question #148393 in C++ for Jochelle Buenaventura

Question #148393

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. 


1
Expert's answer
2020-12-02T12:25:18-0500
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog