View All C Programs

 Previews Example  View All C Programs Next Example 

Program to Check Vowel or Consonant in c

Alphabets a, e, i, o and u are known as vowels and all alphabets except these characters are known as consonants. This program asks user to enter a character and checks whether that character is vowel or not.
#include <stdio.h>
int main(){
  char c;
  printf("Enter an alphabet: ");
  scanf("%c",&c);
  if(c=='a'||c=='A'||c=='e'||c=='E'||c=='i'||c=='I'||c=='o'||c=='O'||c=='u'||c=='U')
       printf("%c is a vowel.",c);
  else
       printf("%c is a consonant.",c);
  return 0;
}
Result
Enter an alphabet: i
i is a vowel.

Enter an alphabet: G
G is a consonant.