Check whether a character Vowel or Consonant

 #include <stdio.h>


int main()
{
    char x;
    int lowercase_voweluppercase_vowel;
    printf("Enter a letter:\n");
    scanf("%c", &x);

    lowercase_vowel = (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u');

    uppercase_vowel = (x == 'A' || x == 'E' || x == 'I' || x == 'O' || x == 'U');

    if (lowercase_vowel || uppercase_vowel)
    {
        printf("The character is a Vowel\n");
    }
    else
    {
        printf("The character is a Consonant\n");
    }

    return 0;
}

Now just type any letter from alphabet and in output you can see the result.

hope this will help you. Happy programming

Comments

Popular posts from this blog

Simple Rock Paper Scissors Game(Java)

Access denied in VS code for gcc while doing C programming

HackerRank 30 Days Of Code Challenge, Day8(Ques 9 in Java)