C Programming Code Examples C > If Else and Switch Case Code Examples C program to check vowel or consonant C program to check vowel or consonant Write a C program to check whether an alphabet is vowel or consonant using if else. How to check vowels and consonants using if else in C programming. C Program to input a character from user and check whether it is vowel or consonant. English alphabets a, e, i, o and u both lowercase and uppercase are known as vowels. Alphabets other than vowels are known as consonants. Input a character from user. Store it in some variable say ch. Check conditions for vowel i.e. if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'), then it is vowel. If character is alphabet but not vowel then it is consonant. Means check ch >= 'a' && ch <= 'z' then, it is consonant. If it is neither vowel nor consonant, then it is not alphabet. Character in C is represented inside single quote. Do not forget to add single quote whenever checking for character constant. Let us implement the logic with both lower and upper case alphabets. #include <stdio.h> int main() { char ch; /* Input character from user */ printf("Enter any character: "); scanf("%c", &ch); /* Condition for vowel */ if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' || ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U') { printf("'%c' is Vowel.", ch); } else if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { /* Condition for consonant */ printf("'%c' is Consonant.", ch); } else { /* * If it is neither vowel nor consonant * then it is not an alphabet. */ printf("'%c' is not an alphabet.", ch); } return 0; }