C Online Compiler
Example: C program to check whether a character is vowel or consonant using if else
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// C program to check whether a character is vowel or consonant using if else #include <stdio.h> #include <ctype.h> // this header file loaded for check the charcters int main() { char random_character; int lowercase = 0, uppercase = 0; printf("Enter a character to check: "); scanf("%c", &random_character); // isalpha() function will check // whether character is alphabetic or non-alphabetic if (random_character && isalpha(random_character)) { // it will be return 1 // if input character matched with these small characters lowercase = random_character == 'a' || random_character == 'e' || random_character == 'i' || random_character == 'o' || random_character == 'u'; // it will be return 1 // if input character matched with these capital characters uppercase = random_character == 'A' || random_character == 'E' || random_character == 'I' || random_character == 'O' || random_character == 'U'; if (lowercase || uppercase) printf("\n'%c' is a vowel character.\n", random_character); else printf("\n'%c' is a consonant character.\n", random_character); } else { printf("\nSorry, You entered Non-Alphabetic character!\n"); } return 0; }
A
Output
Clear
ADVERTISEMENTS