C-programming - To check for vowel, C program to find vowel or not

To check for vowel

This code checks whether an input alphabet is a vowel or not. Both lower-case and upper-case are checked.


#include<stdio.h>
#include<conio.h>
 
main()
{
      char ch;
 
      printf("Enter a character\n");
      scanf("%c",&ch);
 
      if ( ch == 'a' || ch == 'A' || ch == 'e' || ch == 'E' || ch == 'i' || ch == 'I' || ch =='o' || ch=='O' || ch == 'u' || ch == 'U')
         printf("%c is a vowel.\n", ch);
      else
          printf("%c is not a vowel.\n", ch);
 
      return 0;
}



In the above program, a character is entered. The character is compared with all the vowels in both lower and upper case using OR operator and the output is printed.

Output

Enter a character
s
s is not a vowel.


The topic on C-programming - To check for vowel is posted by - Shree

Hope you have enjoyed, C-programming - To check for vowelThanks for your time

Tech Bluff