Please disable your adblock and script blockers to view this page
 

Program to check for vowel or consonant using switch case in C Language

Introduction: In this article i am going to explain the program that demonstrates how to check whether entered character is vowel or consonant using switch-case statement in C Language. 

As we know there are 5 vowels in the 26 English alphabets ,rest are consonants. So the concept is very simple.  If entered character matches any of the small or capital letter 'a', 'e', 'i', 'o', 'u' ,'A', 'E', 'I', 'O', 'U' then it is vowel else not. In technical term if character matches any of the switch expression defined in the switch body in the form of cases the the control is transferred to that block otherwise to the default case.

Implementation: Let's create a program to check.

#include<conio.h>
#include<stdio.h>
main()
{
      char ch;
      printf("Enter any character from  A to Z :=");
      scanf(" %c",&ch);
      switch(ch)
      {
      case 'A':
           printf(" Vowel");
           break;
          
      case 'E':
           printf("Vowel");
           break;
     
      case 'I':
           printf("Vowel");
           break;
     
      case 'O':
           printf("Vowel");
           break;
     
      case 'U':
           printf("Vowel");
           break;
     
      case 'a':
           printf("Vowel");
           break;
          
      case 'e':
           printf("Vowel");
           break;
     
      case 'i':
           printf("Vowel");
           break;
     
      case 'o':
           printf("Vowel");
           break;
     
      case 'u':
           printf("Vowel");
           break;                                        
            
      default:
           printf("Consonant");
      }     
      getch();             
      }

OUTPUT:

First Run:
 Enter any character from  A to Z := e
 Vowel

Second Run:
 Enter any character from  A to Z := k
 Consonant

Now over to you:

"If you like my work; you can appreciate by leaving your comments, hitting Facebook like button, following on Google+, Twitter, Linked in and Pinterest, stumbling my posts on stumble upon and subscribing for receiving free updates directly to your inbox . Stay tuned and stay connected for more technical updates."
Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily.. ConversionConversion EmoticonEmoticon