Check if an alphabet is vowel or consonant - C

Write a C program to read an alphabet from user and check if it is vowel or consonant.

Solution:

#include<stdio.h>
int main()
{
     char ch;
     printf("Enter Any Alphabet : ");
     scanf("%c", &ch);
     printf("-----------------------\n\t");
     switch(ch)
     {
          case 'a':
          case 'A':
               printf("VOWEL");
               break;        
          case 'e':
          case 'E':
               printf("VOWEL");
               break;        
          case 'i':
          case 'I':
               printf("VOWEL");
               break;        
          case 'o':
          case 'O':
               printf("VOWEL");
               break;        
          case 'u':
          case 'U':
               printf("VOWEL");
               break;
          default:
               printf("CONSONANT");
     }
      return 0;
}


Note: Following is an alternate way to write above program.

#include<stdio.h>
int main()
{
     char ch;
     printf("Enter Any Alphabet : ");
     scanf("%c", &ch);
     printf("-----------------------\n");
     switch(ch)
     {
          case 'a':
          case 'A':
          case 'e':
          case 'E':
          case 'i':
          case 'I':
          case 'o':  
          case 'O':
          case 'u':
          case 'U':
               printf("\tVOWEL");
               break;
          default:
               printf("\tCONSONANT");
     }
     return 0;
}


Output:

vowel consonant