C Program to Check Vowel or Consonant
Write a C Program to find vowel or consonant using if-else statement ?
In English, A, E, I, O, and U are the five alphabets which are known as Vowels.Except these five alphabets all the remaining alphabets are called as consonants. In this tutorial, we will show you, How to write a C Program to check Vowel or Consonant with the explanation.
C Programming Code:
#include<stdio.h>
int main()
{
char alphabet;
int lowercase,highercase;
printf(“enter the charter”);
scanf(“%c”,&alphabet);
lowercase=(alphabet==’a’||alphabet==’e’|| alphabet==’i’||alphabet==’o’||alphabet==’u’);
highercase=(alphabet==’A’||alphabet==’E’|| alphabet==’I’||alphabet==’O’||alphabet==’U’);
if(lowercase||highercase)
{
printf(“%c is vowel\n”,alphabet);
}
else
{
printf(“%c is consonant\n”,alphabet);
}
return 0;
}
Explanation:
The user will first ask to enter any character, and then we are assigning the character to the previously declared variable.
Then, we used the If Else Statement to check whether the character entered by the user is equal to, A, E, I, O, U, for both upper and lower case. And if it is TRUE, it is a Vowel otherwise, it’s a Consonant.
Leave a comment if you have any doubt or difficulties.