C Program to Check Whether an Alphabet is Vowel or Consonant Using if-else
In this tutorial, we are going to see how to write a C program to check whether an alphabet is a vowel or consonant using if-else. There are six alphabets (A, E, I, O, U, and Y) are called vowels. All the remaining alphabets except these five are called consonants. There are three ways to check whether an alphabet is a vowel or consonant, by using if-else, switch-case, or by function.
C Program to Check Whether an Alphabet is Vowel or Consonant Using if-else
#include <stdio.h> int main() { char c; printf("Enter a character: "); scanf(" %c", &c); if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y' || c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y') { printf("\n %c is a vowel.", c); } else { printf("\n %c is a consonant.", c); } return 0; }
Output:
Enter a character: a a is a vowel.
One thought on “C Program to Check Whether an Alphabet is Vowel or Consonant Using if-else”