C program to check whether entered character is Vowel or consonant:
In this example we will check whether the character entered by user is Vowel or Consonant by using If...Else statement.
There are 5 Vowels in English alphabet i.e. A E I O U except these all are Consonants.
Note: Inpute value here is considered as character only.
#Example
#include <stdio.h>
void main()
{
char alpVal;
printf("Enter a character: ");
scanf("%c",&alpVal);
if(alpVal == "a" || alpVal == "e" || alpVal == "i" || alpVal == "o" || alpVal == "u")
{
printf("%c is vowel character.",alpVal);
}
else if("alpVal == "A" || alpVal == "E" || alpVal == "I" || alpVal == "O" || alpVal == "U")
{
printf("%c is vowel character.",alpVal);
}
else
{
printf("%c is consonant character.",alpVal);
}
}
Output:
Enter a character: A A is vowel character.

0 comments:
Post a Comment