adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C to check a given character is vowel or consonant Using switch case.

Program in C to check a given character is vowel or consonant Using switch case.




#include<stdio.h>
   int  main()
     {
      char ch;
      printf("Enter a character:-");
      ch=getchar();
      switch(ch)
       {
        case 'a':
        case 'A':
        case 'e':
        case 'E':
        case 'i':
        case 'I':
        case 'o':
        case 'O':
        case 'u':
        case 'U':
            printf("%c is vowel.",ch);
            break;
        default :
            printf("%c is consonant.",ch);
      }
   return 0;
 }
Output:-








Second method

#include<stdio.h>
#include<ctype.h>
   int  main()
     {
      char ch;
      printf("Enter a character:-");
      ch=getchar();
      switch(toupper(ch))
       {
        case 'A':
        case 'E':
        case 'I':
        case 'O':
        case 'U':
            printf("%c is vowel.",ch);
            break;
        default :
            printf("%c is consonant.",ch);
      }
   return 0;
 }
Output:-




Post a Comment

0 Comments