Check Character is Vowel or Consonant C Program

By | September 2, 2016

C Program To Check if Character is Vowel or Not

Learn How To Check if Character is Vowel or Not in C Programming. This Program makes use of If Else Block and Switch Case to Find if the Entered Character is a Vowel or a Consonant. This program compares the characters with Vowels using ASCII Values.

Method 1: C Program To Check if Entered Character is Vowel or Consonant using If Else

#include<stdio.h>

int main()
{
      char ch;
      printf("\nEnter A Character:\t");
      scanf("%c", &ch);
      if((ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') ||(ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U' ))
      {
            printf("\n%c is a Vowel\n", ch);
      }
      else
      {
            printf("\n%c is a Consonant\n", ch);
      }
      return 0;
}

Method 2: C Program To Find if Character is Vowel or Not using Switch Case

#include<stdio.h>

int main()
{
      char ch;
      printf("\nEnter A Character:\t");
      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("\n%c is a Vowel\n", ch);
                      break;
            default:  printf("\n%c is a Consonant\n", ch);
      }
      return 0;
}

Output

C Program To Check if Entered Character is Vowel or Consonant

If you have any compilation error or doubts in this C Program to Find if the Character is a Vowel or Not, let us know about it in the Comment Section below.

Recommended Programs
C Program To Check if a Character is Alphabet or Not
C Program To Convert String into Uppercase Characters
C Program To Read Contents of a File
C Program To Display Hello World without Semicolon
C Program To Display A Christmas Tree
C Program For Swapping Numbers using Call By Value
C Program To Print Multiplication Table of a Number

3 thoughts on “Check Character is Vowel or Consonant C Program

  1. Gurpreet Singh

    I think the If Else Block is much more easier than Switch case as we can enlist all the vowels in a single statement.

    Reply
  2. Vir Das

    This is a new type of working of Switch case. I had not seen anything of this sort before.

    Reply

Let's Discuss