C Program To Check Vowel Or Consonant

This program checks whether the input character is Vowel or Consonant. In addition to this, this program also checks whether the given input is a digit or special symbol.

This program asks the user to input a choice to enter a character. It asks the user to enter ‘y’ oy ‘Y’ for yes and ‘n’ or ‘N’  for No. When the user input ‘y’ or ‘Y’ to signify yes, the program ask user to enter character.

When the user inputs character it is checked for three  cases – first, using the switch case statement it checks for Vowel or Consonant, second, using if condition it checks whether the given input is digit or not and third, it concludes that if the given input is not Vowel or Consonant or digit than it is special character.

After checking the given input, the program again asks the user to choose to enter a character. If the user inputs ‘Y’ or ‘y’ then user input is taken again. If the user inputs ‘n’ or ‘N’ then the program terminates.

#include <stdio.h>
#include<stdlib.h>
int main(void) 
{
         char ch,choice;
  
         printf("\n");
         printf("\n Want to enter character , Press 'Y' for yes and 'N' for No \n");
         scanf(" %c", &choice);

         while(choice=='Y'||choice=='y')
         {
             printf("\n Enter character \n");
             scanf(" %c",&ch);
     
             if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
             {
                   printf("\n");
             switch(ch)
             {
                    case 'a':
                                 printf("\n");
                                 printf("Input character is Vowel");
                          break;

                    case 'e':
                                 printf("\n");
                                 printf("Input character is Vowel");
                          break;

                    case 'i':
                                 printf("\n");
                                 printf("Input character is Vowel");
                          break;
                   
                     case 'o':
                                printf("\n");
                                printf("Input character is Vowel");
                          break;
            
                      case 'u':
                                printf("\n");
                                printf("Input character is Vowel");
                          break;
            
                     case 'A':
                                printf("\n");
                                printf("Input character is Vowel");
                           break;
            
                    case 'E':
                               printf("\n");
                               printf("Input character is Vowel");
                           break;
                   
                      case 'I':
                              printf("\n");
                              printf("Input character is Vowel");
                          break;
            
                      case 'O':
                              printf("\n");
                              printf("Input character is Vowel");
                           break;
            case 'U':
                    printf("\n");
                    printf("Input character is Vowel");
                break;
            
             default:
                    printf("\n");
                    printf("Input character is Consonant");
          }
      }
      else if(ch >= '0' && ch <= '9')
      {
          printf("\n");
          printf(" %c is digit.", ch);
      }
      else 
      {
          printf("\n");
          printf(" %c is special character.", ch);
      }
      printf("\n");
      printf("\n Want to enter character again, Press 'Y' for yes and 'N' for No \n");
      scanf(" %c", &choice);
      if(choice=='Y'    ||    choice=='y'    ||     choice == 'N'   || choice == 'n')
      {
         
      }
      else
      {
           printf("\n You have entered incorrect choice \n");
           exit(1);
      }
      
   }
  return 0;
}
Want to enter character , Press 'Y' for yes and 'N' for No
y
 
Enter character
q
Input character is Consonant
 
Want to enter character again, Press 'Y' for yes and 'N' for No
y
 
 Enter character
a
 
Input character is Vowel
 
Want to enter character again, Press 'Y' for yes and 'N' for No
y
 
 Enter character
5

5 is a digit.
 
Want to enter character again, Press 'Y' for yes and 'N' for No
y
 
 Enter character
]
 
 ] is a special character.
 
 Want to enter character again, Press 'Y' for yes and 'N' for No
n