Write a program that takes a character as input and determines whether it’s a vowel or a consonant.
#include <stdio.h>
int main() {
// Declare variable
char character;// Input: Get a character from the user
printf(“Enter a character: “);
scanf(” %c”, &character); // Note the space before %c to consume any previous newline character// Process: Determine if the character is a vowel or a consonant
if ((character >= ‘a’ && character <= ‘z’) || (character >= ‘A’ && character <= ‘Z’)) {
// Check if the character is a vowel
if (character == ‘a’ || character == ‘e’ || character == ‘i’ || character == ‘o’ || character == ‘u’ ||
character == ‘A’ || character == ‘E’ || character == ‘I’ || character == ‘O’ || character == ‘U’) {
printf(“%c is a vowel.n”, character);
} else {
printf(“%c is a consonant.n”, character);
}
} else {
printf(“%c is not a valid alphabetical character.n”, character);
}return 0; // Exit the program successfully
}