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

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

C Program to Check Vowel or Consonant

In the English language, the letters A, E, I, O, U and a, e, i, o, u are defined as a vowel. Except these all other letters are consonants. We can write a c program to check vowels or consonants using an if-else statement or by using switch-case statements.

C Program to Check Whether a Character
#include <stdio.h>
int main() 
{
    char c;
    int lowercase_voweluppercase_vowel;
    printf("Enter an Alphabet: ");
    scanf("%c", &c);
    lowercase_vowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');
    uppercase_vowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');
    if (lowercase_vowel || uppercase_vowel)
        printf("%c is a Vowel."c);
    else
        printf("%c is a Consonant."c);
    return 0;
}

Output:
Enter an Alphabet: E E is a Vowel.
Enter an Alphabet: S
S is a Consonant.

Run Code: If you want run this code copy this code, paste here and run.


No comments: