C Program to Check Whether a Character is Vowel or Consonant

Program


#include<stdio.h>
#include<conio.h>

int main()
{
	 char ch;
	 clrscr();
	 printf("Enter any character: ");
	 scanf("%c", &ch);
	
	 /* Converting to lowercase if it is uppercase  */
	 ch = ch>='A'&&ch<='Z'?ch+32:ch;
	
	 if(ch>='a'&&ch<='z')
	 {
		  if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
		  {
		   	printf("It is vowel.");
		  }
		  else
		  {
		   	printf("It is consonant.");
		  }
	 }
	 else
	 {
	  	printf("It is neither vowel nor consonant.");
	 }
	 getch();
	 return(0);
}

Output of above program :

Run 1:
-------------
Enter any character: F ↲
It is consonant.

Run 2:
-------------
Enter any character: a ↲
It is vowel.

Run 3:
-------------
Enter any character: E ↲
It is vowel.

Run 4:
-------------
Enter any character: * ↲
It is neither vowel nor consonant.

Note: ↲ indicates ENTER is pressed.