vowel or consonant in c

Vowel or Consonant in C

In the C programming language, you can determine whether a character is a vowel or a consonant by using conditional statements and character comparison. Here's an example code snippet that checks if a character is a vowel or a consonant in C:

#include <stdio.h>

int main() {
    char ch;

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

    // Convert the character to lowercase
    ch = tolower(ch);

    if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') {
        printf("%c is a vowel.\n", ch);
    } else if ((ch >= 'a' && ch <= 'z')) {
        printf("%c is a consonant.\n", ch);
    } else {
        printf("Invalid input.\n");
    }

    return 0;
}

This code prompts the user to enter a character and then checks if it is a vowel or a consonant. The tolower() function is used to convert the character to lowercase before comparison. If the character is one of the vowels ('a', 'e', 'i', 'o', 'u'), it is considered a vowel. If the character is a lowercase letter but not a vowel, it is considered a consonant. If the character is not a lowercase letter, it is considered an invalid input.

Please note that this code snippet is a basic example and does not handle special cases or non-alphabetic characters. You can modify it according to your specific requirements.