In this tutorial you will learn about the C Program to Check Vowel or Not and its application with practical example.
C Program to Check Vowel or Not
In this tutorial, we will learn to create a C program that will Check Vowel or Not using C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Conditional Statements in C programming.
- String concepts in C Programming.
Program to Check Vowel or Not
In c programming, it is possible to take character input from the user and Check Vowel or Not with the help of a very small amount of code. The C language has many types of header libraries which has supported function in them with the help of these files the programming is easy. The string manipulation is very easy in C programming. In today’s program, we will take a character in input and Check Vowel or Not.
With the help of this program, we can Check Vowel or Not.
Algorithm:-
1 2 3 4 5 6 7 8 9 |
1. Declaring the variables for the program. 2. Taking the input a character from the user. 3. Pass that character to check with condition for vowel. 4. Printing the vowel or consonant. 5. End Program. |
Program to Check Vowel or Not:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
/* C Program that will Check the given character is a vowel or consonant */ #include <stdio.h> int main() { //Declaring the variables for the for the program char c; int lowerchar, upperchar; //Taking the input character from the user printf("Enter an alphabet: "); scanf("%c", &c); // first if variable c is in a lowercase vowel lowerchar = (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'); // second if variable c is in a uppercase vowel upperchar = (c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U'); // if c is a vowel //printing the output for vowel else consonant if (lowerchar || upperchar) printf("%c is a vowel.", c); else printf("%c is a consonant.", c); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- c= it will hold the character value.
- lowerchar= it will hold the integer value.
- upperchar= it will hold the integer value.
Input character from the user.
Program Logic Code.
Printing output Check Vowel or Not.