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

C program to find the greatest of three numbers with user input.

How to add to integers in C programming