Subscribe for more such posts..

Dear Reader...
I hope u are like my posts. If so then please don't forget to like , share and follow my blog for more such posts ,also feel free to write suggestions in the comment box given over here.

Thank you...

Search This Blog

C program to check whether a character is an alphabet or not and if it is an alphabet then check whether it is a vowel or a consonant using if-else and switch.

#include <stdio.h>
int main()
{
	char c;
	
	
	
	printf("Enter a character : ");
	scanf("%c" , &c);
	
	if((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
	{
		
		if (c == 'a' || c == 'A' || c =='E' || c == 'e' || c == 'I' || c == 'i' ||  c ==  'O' ||  c == 'o'  || c == 'U' || c == 'u') 
			
		{	
			
			printf("%c is an alphabet and a vowel\n" , c);
			
		}
			
		else
		{
			 printf("%c is an alphabet and a consonant\n" , c);
		}
			
			
		
	}

	else 
	{
		printf("%c is not an alphabet\n" , c);
	}
	
	return 0;
	
}





No comments:

Post a Comment