Easy Tutorial
❮ C Function Remove C Function Tmpfile ❯

C Language Example - Identifying Vowels/Consonants

C Language Examples

Determine whether the input letter is a vowel or a consonant.

English has 26 letters, with vowels including only a, e, i, o, u. The rest are consonants. Y is considered a semi-vowel, semi-consonant letter, but in English, it is generally treated as a consonant.

Example

#include <stdio.h>

int main()
{
    char c;
    int isLowercaseVowel, isUppercaseVowel;

    printf("Enter a letter: ");
    scanf("%c", &c);

    // Lowercase vowel
    isLowercaseVowel = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u');

    // Uppercase vowel
    isUppercaseVowel = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U');

    // if statement to check
    if (isLowercaseVowel || isUppercaseVowel)
        printf("%c is a vowel", c);
    else
        printf("%c is a consonant", c);
    return 0;
}

Run Result:

Enter a letter: G
G is a consonant

C Language Examples

❮ C Function Remove C Function Tmpfile ❯