C Program to Check Whether a Character is Vowel or Consonant Using if and else

Using this tutorial, We are going to discuss the topic of “C Program to Check Whether a Character is Vowel or Consonant Using if and else” below. Let’s start the discussion to do this task successfully.

C Program to Check Whether a Character is Vowel or Consonant Using if and else

C Program to Check Whether a Character is Vowel or Consonant Using if and else

Program Code

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

  printf("Input a charactern");
  scanf("%c", &ch);

  if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' &&ch <= 'Z')) {
    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 a consonant.n", ch);
  }
  else
    printf("%c is neither a vowel nor a consonant.n", ch);

  return 0;
}

Final Thoughts

I hope this article helps you to understand “C Program to Check Whether a Character is Vowel or Consonant Using if and else”. If you have any doubts regarding this article please let us know via the comment section. Share this article with your friends via social networks. Thank You!

Share on:

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Comment