C Program to Check Whether an Alphabet is Vowel or Consonant Using if-else
In this tutorial, we are going to see how to write a C program to check whether an alphabet is a vowel or consonant using if-else. There are six alphabets (A, E, I, O, U, and Y) are called vowels. All the remaining alphabets except these five are called consonants. There are three ways to check whether an alphabet is a vowel or consonant, by using if-else, switch-case, or by function.
C Program to Check Whether an Alphabet is Vowel or Consonant Using if-else
#include <stdio.h>
int main()
{
char c;
printf("Enter a character: ");
scanf(" %c", &c);
if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'y' ||
c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y') {
printf("\n %c is a vowel.", c);
}
else {
printf("\n %c is a consonant.", c);
}
return 0;
}
Output:
Enter a character: a a is a vowel.





//check whether a alphabet is a vowel or not in c #include #include int main(void) { int i,flag=0; char c,vowel[20]={"aeiouAEIOU"}; printf("enter the character\n"); setbuf(stdout,NULL); scanf("%c",&c); for(i=0;i<=10;i++){ if(c==vowel[i]){ flag=1; break; } }if(flag==0){ printf("the entered character is not a vowel"); }else{ printf("the entered character is vowel"); } return EXIT_SUCCESS; }