C Program to check whether input alphabet is vowel or not

Here is a simple C program to check input alphabet is vowel or not. In alphabet a,e,i,o,u,A,E,I,O and U are vowel. If input alphabet is one of these vowel, program will give output that alphabet is vowel.
#include<stdio.h>
int main()
{
 char ch;
 printf("Enter a alphabet: ");
 scanf("%c",&ch);
 if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
 {
  printf("alphabet is vowel \n");
 }
 else
 if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
 {
  printf("Alphabet is vowel \n");
 }
 else
 {
  printf("alphabet is not vowel \n");
 }
 return 0;
}
Check vowel using switch loop
#include<stdio.h>
int main()
{
 char ch;
 printf("Enter a alphabet: ");
 scanf("%c",&ch);
 switch(ch)
 {
     case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
  case 'A':
  case 'E':
  case 'I':
  case 'O':
  case 'U':
  printf("Alphabet is vowel \n");
  break;
  default:
  printf("Alphabet is not vowel \n");  
 }
 return 0;
}



Popular posts from this blog