To understand this program, you should have knowledge of these C programming Topics :
- C programming Operators
- if-else statement in C
Write a program for check whether a character is vowel or consonant in C?in C
Program
#include <stdio.h>
void 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 Vowel.\n", c);
else
printf("%c is Consonant.\n",c);
}
else
printf("\n%c is Invalid Character.", c);
}
void 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 Vowel.\n", c);
else
printf("%c is Consonant.\n",c);
}
else
printf("\n%c is Invalid Character.", c);
}
Output
Enter a character : a
a is Vowel
0 Comments
If You Have Any Doubt, Please Let Me Know,