A Character Is Vowel Or Consonant

Character is a Vowel or a Consonant

Five alphabets out of the 26 alphabets are known as Vowels. These are A, E, I, O, and U. The remaining 21 alphabets are known as the consonants. A computer program can test whether the entered character is a vowel or a consonant. This can be done by comparing the entered character with a set of vowels and consonants. If the character matches with a, e, i, o, or u, or A, E, I, O, or U, it is a vowel. Otherwise, if it matches with any other character, it is consonant.

Algorithm to Check Whether a Character is a Vowel or a Consonant

Step 1. Start

Step 2. Enter the character  

Step 3. Compare the character with lowercase vowels, return true in a condition of the match.

Step 4.  Compare the character with uppercase vowels, return true in a condition of the match.

Step 5. Stop

Read Also: A Number Is Even Or Odd

C Program to Check Whether a Character is a Vowel or a Consonant

#include <stdio.h>
#include <conio.h>
int main()
{
    char a;
    int Lowercase, Uppercase;
    printf("Enter an alphabet: ");
    scanf("%c",&a);
    // returns 1 if a is a lowercase vowel
   Lowercase = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
    // returns 1 if a is an uppercase vowel
    Uppercase = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
    // returns 1 if either of Lowercase or Uppercase is true
    if (Lowercase || Uppercase)
        printf("%a is a vowel.", c);
    else
        printf("%a is a consonant.", c);
    return 0;
}

Output

Enter an alphabet: A

A is a vowel.