FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 98   



Following program shows you how to take a character and tells its vowel or consonant.
In this program we get a character from user and shows it's vowel or consonant using if condition

#include <iostream>
#include <string>

int main() {
    char input;
    std::cout << "Please enter a character:";
    std::cin >> input;
    if (input == 'a' || input == 'A' || input == 'e' || input == 'E' ||
        input == 'i' || input == 'I' || input == 'o' || input == 'O' ||
        input == 'u' || input == 'U') {
        std::cout << "Its a vowel";
    } else if (
        (input >= 'a' && input <= 'z') || (input >= 'A' && input <= 'Z')) {
        std::cout << "Its a consonant";
    } else {
        std::cout << "Its not an alphabet";
    }
}

Output:

Example1:

Please enter a character: e
Its a vowel

Example2:

Please enter a character: x
Its a consonant

Example3:

Please enter a character: 3
Its not an alphabet



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News