C Program to Check Vowel or Consonant

In this blog post, we learn how to write a C program to check vowel or consonant?. We will write the C program to check vowel or consonant using the if-else statement. 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.

There are 5 vowels in English alphabets, these are a, e, i, o, u. These vowels can be in uppercase or lowercase.

#include <stdio.h>

int main()
{
    char ch;
    // Get input from the user
    printf("\n Enter any character: ");
    scanf("%c", &ch);
    //check alphabate
    if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
    {
        // check for vowel
        if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u' ||
                ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U')
        {
            printf("\n It is an vowel.\n\n");
        }
        else
        {
            printf("\n It is a consonant.\n\n");
        }
    }
    else
    {
        printf("\n It is not an vowel nor consonant.\n\n");
    }
    return 0;
}

Output 1:

C program to check vowel or consonant

 

Output 2:

C program to check vowel or consonant

Output 3:

C program to check vowel or consonant