C Program To Check Vowel or Consonant

In this article, we are going to write a c program to check whether an alphabet is vowel or consonant

We will make this program in the following way -:

  • C Program To Check Vowel or Consonant Using if else
  • C Program To Check Vowel or Consonant Using Switch Case
  • C Program To Check Vowel or Consonant Using Function

To make this program, we will use the following concept given below.

If you do not know about these topics well, then you may not understand this program, so you should know about them in detail from the link given above.

Now without wasting time let’s start programming.

C Program To Check Vowel or Consonant

C Program To Check Vowel or Consonant Using If else Statement

Algorithm

  • Program Start
  • Declare Variable
  • Input Character
  • Check Conditions
  • Display Result Accourding to condition
  • Program End

Program

//C Program To Check Vowel or Consonant Using If else Statement 

#include <stdio.h>
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  // Checking both lower and upper case, || is the OR operator

  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 isn't a vowel it is a Consonant\n", ch);

}

Output

Enter a character : t
t isn't a vowel it is a Consonant

C Program To Check Vowel or Consonant Using Switch Case Statement

Program

//C Program To Check Vowel or Consonant Using Switch Case Statement

#include <stdio.h>
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  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 a vowel.\n", ch);
      break;
    default:
      printf("%c isn't a vowel it is a Consonant\n", ch);

}
}

Output

Enter a character : e
e is a vowel.

C Program To Check Vowel or Consonant Using Function

Algorithm

  • Program Start
  • Declare Variable
  • Input Character
  • Calling Function To Check Vowel Or Consonant
  • Check Conditions
  • Display Result Accourding to condition
  • Program End

Program

//C Program To Check Vowel or Consonant Using Function

#include <stdio.h>
void checkvowelorConsonant(char ch)
{
// Checking both lower and upper case, || is the OR operator

  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 isn't a vowel\n", ch);

}
void main()
{
  char ch;

  printf("Enter a character : ");
  scanf("%c", &ch);

  checkvowelorConsonant(ch);
}

Output

Enter a character : O
O is a vowel.

Conclusion

So friends, in this article, we have written a c program to check whether an alphabet is vowel or consonant in this ways.

  • C Program To Check Vowel or Consonant Using if else
  • C Program To Check Vowel or Consonant Using Switch Case
  • C Program To Check Vowel or Consonant Using Function

If you have difficulty to understand any program or have any doubts or questions, then tell me in the comment below.

Jeetu Sahu is A Web Developer | Computer Engineer | Passionate about Coding, Competitive Programming, and Blogging

Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.