A Program to Check a Character is Vowel or Consonant
In this example, we are giving a program which is useful to check whether a character given by the user is vowel or consonant.
Program to check Vowel or Consonant:
#include <stdio.h>int main(){char c;int isLowercaseVowel, isUppercaseVowel;printf("Enter an alphabet: ");scanf("%c",&c);// true if c is a lowercase vowelisLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');// true if c is an uppercase vowelisUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');// true if either isLowercaseVowel or isUppercaseVowel is trueif (isLowercaseVowel || isUppercaseVowel)printf("%c is a vowel.", c);elseprintf("%c is a consonant.", c);return 0;}
Output:
Enter a character: E E is a vowel.