Check whether a character Vowel or Consonant
#include <stdio.h>
int main()
{
char x;
int lowercase_vowel, uppercase_vowel;
printf("Enter a letter:\n");
scanf("%c", &x);
lowercase_vowel = (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u');
uppercase_vowel = (x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U');
if (lowercase_vowel || uppercase_vowel)
{
printf("The character is a Vowel\n");
}
else
{
printf("The character is a Consonant\n");
}
return 0;
}
Now just type any letter from alphabet and in output you can see the result.
hope this will help you. Happy programming
Comments
Post a Comment