In this C programming example, if...elseif...else statement is used to check whether an alphabet entered by the user is an alphabet or not and if alphabet, whether vowel or a constant. It check the entered character for both lowercase and uppercase alphabets. If user enters input other than a character, it displays appropriate output message.
C program to check vowel or consonant - Source code
Program Output
Program Explanation
1. Input a character from user. Store it in the character variable ch.
2. Check condition for being the vowel i.e. if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u'
ch=='A' || ch=='E' || ch=='I' || ch=='O' || ch=='U').
3. Check for the consonant using the expression ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')).
4. In the last else statement , If it is neither vowel nor consonant, then it is not alphabet or some other character.
5. Characters in C are represented inside single quotes.
need an explanation for this answer? contact us directly to get an explanation for this answer