In this tutorial, you will learn to write a program to check whether a character is a vowel or constant using if-else. Here, we are using examples, and algorithms with fully explained programs for your better understanding of this problem. This topic is also suited for checking whether an input character is a vowel or consonant in the C program using if-else.Problem StatementWe have to Write a C program that checks whether a given character is a vowel or a consonant. Our program should take a character as input and after checking they should spring a character as a vowel or consonant.ExampleEnter a character: AOutput: The character A is a vowel.Enter a character: ZOutput: The character Z is a consonant.Algorithm to Check Character Is A Vowel Or Consonant Using If-else- Start the program.- Declare a variable character of type char to store the input character.- Prompt the user to enter a character by printing the message "Enter a character: ".- Read the input character from the user and store it in the character variable using scanf().- Convert the character to uppercase using the toupper() function to handle lowercase inputs.- Use an if-else statement to check if the input character is a vowel or a consonant:- If character is equal to 'A', 'E', 'I', 'O', or 'U', print the message "The character is a vowel."- Otherwise, print the message "The character is a consonant."- End the program.C Program to check whether a character is a vowel or consonant #include #include int main() { char character; printf("Enter a character: "); scanf(" %c", &character); character = toupper(character); if (character == 'A' || character == 'E' || character == 'I' || character == 'O' || character == 'U') { printf("The character %c is a vowel.n", character); } else { printf("The character %c is a consonant.n", character); } return 0;}Output 1Enter a character: AThe character A is a vowelOutput 2Enter a character: SThe character S is a consonantProgram Explanation- The program starts by including the necessary header files: stdio.h for input/output functions and ctype.h for character handling functions.- The main() the function is defined.- Inside the main() function, a variable character of type char is declared to store the input character.- The program prompts the user to enter a character by printing the message "Enter a character: ".- The scanf() function is used to read a character from the user, and the input is stored in the character variable using the %c format specifier. A space is added before %c in scanf to consume any leading whitespace or newline characters from the previous input.- The toupper() function is used to convert the input character to uppercase to handle lowercase inputs.- An if-else statement is used to check if the input character is a vowel or a consonant:- If the input character is 'A', 'E', 'I', 'O', or 'U', the program prints the message "The character is a vowel." The %c format specifier is used in printf() to print the character.- If the input character is not one of the vowels, the program prints the message "The character is a consonant."- The return 0 statement ends the program.ConclusionThis C program allows the user to enter a character and determines whether it is a vowel or a consonant using if-else statements. It covers all possible cases and provides the appropriate output based on the input character.

















