C Program to check for Vowel or Consonant Alphabets

Here you can find the c code for checking whether the entered character is vowel or a consonant. In this program, I have also taken into account few failure cases when the user enters any special characters or any number instead of the expected alphabets. This program is also programmed to allow the user to enter alphabets in any case either Upper or Lower.

One thing which has to be kept in mind is that if the user enters more than one character, only the first character will be considered.

The C code can be found below:

C program to check for vowel or consonant alphabets
By:  http://www.123mylist.com
#include <stdio.h>
#include <conio.h>
int main()
    char c;
    printf("Enter a character to check for vowels\n");
    if((c>='a' && c<='z')|(c>='A' && c<='Z'))
        if(c=='a' | c=='e' | c=='i' | c=='o' | c=='u' | c=='A' | c=='E' | c=='I' | c=='O' | c=='U' )
        printf("Enter Only Alphabets");

    return 0;

Content is copyrighted © www.123mylist.com