How to Check Vowel or Consonant in C Programming
The English characters a, e, i, o, and u are lowercase and uppercase characters are known as vowels. Alphabets without vowels are known as consonants.Given a c program in below using if-else to check whether an alphabet is a vowel or consonant. In this program, take input a character from the user and check whether it is vowel or consonant.
#include<stdio.h> int main() { char L; // Input character from user printf("nEnter a Lettern"); scanf("%c",&L); if ((L >= 'a' && L <= 'z') || (L >= 'A' &&L <= 'Z')) { // Condition for lowercase vowel if(L=='a'||L=='e'||L=='i'||L=='o'||L=='u') printf("n%c is a Vowel",L); // Condition for uppercase vowel else if(L=='A'||L=='E'||L=='I'||L=='O'||L=='U') printf("n%c is a Vowel",L); else printf("n%c is a Consonant",L);} else printf("%c is a Non-alphabetic character.n", L); getch(); }
Output:01
Enter a Letter A A is a Vowel Process returned 0 (0x0) execution time : 13.206 s Press any key to continue.
Output:02
Enter a Letter 5 5 is a Non-alphabetic character. Process returned 0 (0x0) execution time : 9.194 s Press any key to continue.