C++ Program to Check Whether a character is Vowel or Consonant.

In the following example of C++ program that checks whether a character entered by the user is a vowel or a consonant :
Program :
#include <iostream>

int main() {
    char ch;
    std::cout << "Enter a character: ";
    std::cin >> ch;
    if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' ||
        ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
        std::cout << ch << " is a vowel.";
    else
        std::cout << ch << " is a consonant.";
    return 0;
}
​
Output :
Enter a character: G
G is a consonant.
* This program declares a variable ch of type char. The program then prompts the user to enter a character using the std::cout and std::cin objects from the iostream library.

* The >> operator is used to input the user's character into the ch variable.

* The program then uses conditional statements to determine whether the character is a vowel or a consonant.

* If the character is equal to one of the vowel characters (lowercase or uppercase), the program prints a message saying that the character is a vowel. Otherwise, the program prints a message saying that the character is a consonant. The program uses std::cout to output the message to the console.