Tuesday, 26 March 2019

C Program to Check Whether a Character is Vowel or Consonant


This program demonstrates the functioning of if else statements. Program asks user for an alphabet and gives the output whether alphabet is vowel or consonant.
The five alphabets A, E, I, O and U are called vowels. All other alphabets except these 5 vowel letters are called consonants.
//C Program to Check Whether a alphabet is Vowel or Consonant
#include <stdio.h>
int main()
{
    char ch;
    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'))
        printf("%c is a vowel.\n", ch);
    else
        printf("%c is a consonant.\n", ch);
    return 0;
}
Output:



Please comment if you find anything incorrect, or you want to improve the topic discussed above.

No comments:

Post a Comment