1. zimrukunuzzaman@gmail.com : Zim :
Check Whether a Character is a Vowel or Consonant in C Programming - E-Education BD Check Whether a Character is a Vowel or Consonant in C Programming %
E-Education BD
  • Phone
  • 01518961012
  • Contact
  • eeducationbd21@gmail.com
  • Location
  • Gaibandha,Rangpur
  • Check Whether a Character is a Vowel or Consonant in C Programming

    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.