C program to check whether a character is a vowel or consonant

Logic:

  1. Input a character
  2. Check whether it is a vowel or not for Both lower-case and upper-case are checked.(Vowels are A,E,I,O,U,a,e,I,o,u and other alphabets are consanants)
				
					#include <stdio.h> 
#include<conio.h> 
void main() 
{
char ch; 
clrscr();
printf("Enter a character\n");
scanf("%c", &ch);
// Checking both lower and upper case characters, || is the OR operator 
if (ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
printf("%c is a vowel.\n", ch); 
else  
printf("%c is not a vowel.\n", ch);   
getch(); 
}
				
			

Leave a Reply