Â

In this, we are going to write a simple program to check whether the given character is a vowel or consonant or if it is an invalid character with the help of C programming language.
#include <stdio.h>
void main()
{
char ch;
printf("Enter character to find if it's vowel or consonant \n");
scanf("%c", &ch);
// to check if character entered is an alphabet
// with help of ascii values of alphabets
if (((int)ch >= 97 && (int)ch <= 122) || ((int)ch >= 65 && (int)ch <= 90))
{
// if character is actually alphabet,
// check if its A,a,E,e,I,i,O,o,U,u
if (ch == 'A' || ch == 'a' || ch == 'E' || ch == 'e' || ch == 'I' || ch == 'i' || ch == 'O' || ch == 'o' || ch == 'U' || ch == 'u')
{
printf("You entered VOWEL ");
}
// if alphabet is not vowel its consonent
else
{
printf("You entered CONSONANT ");
}
}
else
{
printf("INVALID character");
}
}
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP