Problem statement
Write a program which take input character from user and determine it is vowel or consonant.
What is vowel and consonant
The letters of the English alphabet are either vowels or consonants.
These alphabets are vowels:
1 |
A, E, I, O, U or a, e, i, o, u |
Rest of the 21 alphabhets are consonants.
Program
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#include<stdio.h> int main() { char ch; printf("Enter the character\n"); scanf("%c", &ch); if((ch=='a') || (ch=='e')||(ch=='i')|| (ch=='o')|| (ch=='u')) { printf("Given character is vowel"); } else printf("Given character is consonant"); } |
Output
1 2 3 |
Enter the character t Given character is consonant |
Explanation
We know that there are 5 vowels. Therefore we use || operator to check multiple conditions.
If you dont know what is || and how it work then check Operators.
Then you will understand the above program.
In above program, we are checking a character with a, e, i, o, u. If anyone of these matches with input character then it is vowel else it is consonant.