Check character is vowel or not is the simple and easy program in c programming.
In this tutorial we see one simple program which is to Check character is vowel or not.
For this we only require to know what are the vowel.
As we know in alphabet their are 5 vowels and remaining are the consonants. vowels are A, E , I, O , U .
Logic for checking vowels :-
1.As we know what’s are the vowel on the alphabet.
So based on that we write a condition.
2. We read character and in if condition we check character with vowel.
3. if the character matches we print it is vowel else it’s consonant.
Algorithm to check vowel
2. Declare character variable to tale input character.
3. Take input character from user.
4. Write a condition to check input character equals to vowel.( we need to check for both upper and lower case alphabet )
5. If true , print character is vowel.
6. Else , print character is consonant.
char c ; //declare variable
printf ("Enter character :");
scanf ("%c",&c); //take input character
//write condition to check vowel
printf ("\n Character is vowel ");
printf ("\n Character is consonant ");
1. First we declare the character variable. char c ;
2. Take a input character from user and store character in c variable. Suppose input character is A. c= A.
3. Now the actual logic starts . Check the input character is vowel. Using if we check for vowel.
if (c == ‘A’ || c == ‘a’ || c==’e’ || c==’E’ || c==’i’ || c==’I’ || c==’o’ || c ==’O’ || c==’u’ || c==’U’)
In this statement, c==’A’ checked and condition become true.
4. Condition is true , statement in if block executed.
Character is vowel.
5. And else block get skipped.
6. And in case of consonant as another input .the if condition become false and statement in if block get skipped and else block get executed.
Character is consonant.