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

In this example, you will learn to check whether a letter entered by the user is Vowel or Consonant.

Program to Check Vowel or Consonant.

Code:

#include<stdio.h>

int main()
{
  
  char letter;
  printf("enter a letter\n");
  scanf("%c",&letter);
   
   
    if(letter>='a'&& letter<='z' ||                   letter>='A'&& letter<='Z' )
    {
       if( letter=='a'||letter=='A'||letter=='e'||letter=='E'||letter=='i'||letter=='I'||letter=='o'||letter=='O'||letter=='u'||letter=='U')
      
       printf("letter is Vowel");
       else
       printf("letter is Consonant");
      
    }
    else
     printf("Not vaild");
   
   
}


In the program, the character entered by the user is stored in the variable letter.

If entered letter is alphabet letter

Then, first if  statement excute,if condition flash control move else part print "not valid".

suppose, entered letter is alphabet letter then first if statement excute.frist statement checked range of alphabet.

Then, second if checked letter vowel ,if condition ture that means letter is vowel 

then control enter second if body part print " letter is vowel"

 if second if condition flash that means control move else part print"letter is consonant"