C

C Program To Determine Whether An Alphabet Letter Is A Vowel Or A Consonant

This program determines whether the character input is a vowel or a consonant.

Program to check for Vowel or Consonant

This program uses an if-else statement to determine whether the character value (entered by the user) is a vowel or a consonant. Because a user can enter an alphabet in both lowercase and uppercase, the program looks for uppercase and lowercase vowels and consonants. You should be familiar with the following C programming concepts in order to understand this program:

  • If statement in C programming
  • If…else statement in C programming
#include <stdio.h>
int main()
{
    char ch;
    bool isVowel = false;

    printf("Enter an alphabet: ");
    scanf("%c",&ch);

    if(ch=='a'||ch=='A'||ch=='e'||ch=='E'||ch=='i'||ch=='I'
    		||ch=='o'||ch=='O'||ch=='u'||ch=='U')
    {
    	isVowel = true;

    }
    if (isVowel == true)
        printf("%c is a Vowel", ch);
    else
        printf("%c is a Consonant", ch);
    return 0;
}

Output:

Enter an alphabet: E
E is a Vowel

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button