C program to input any alphabet and check whether it is vowel or consonant – In this article, we will demonstrate the way to check whether any inputted alphabet is a vowel or consonant in C programming.
Suitable examples and sample programs have also been added so that you can understand the whole thing very clearly. The compiler has also been added with which you can execute it yourself.
In this piece, the method used is as follows:
- Using Standard Method
As given in the image uploaded above, you need to enter a character.
We all know, there are 5 vowels in the 26 alphabets of the English language.
Those are A, E, I, O and U
In this case, it is seen that ‘a’ is the character that has been entered.
So, it is clear that ‘a’ is a vowel. The same thing will be printed on the screen.
Thus, the means to do so in C programming are as follows:
Using Standard Method
- Read the entered character and save in the variable “ch” using scanf() function.
2) Compare “ch” with all vowels(A,a,E,e,I,i,O,o,U,u) using “if” condition.
3) If “ch” matches with any one of the vowels then print ch is a vowel, otherwise print ch is consonant.
printf("Enter a character\n");
printf("%c is a vowel\n",ch);
printf("%c is a consonant\n",ch);
Enter a character
a is a vowel