Professional Documents
Culture Documents
Home C programming C programming examples C program to check whether input alphabet is a vowel or not
This code checks whether an input alphabet is a vowel or not. Both lower-case and upper-case are checked.
C programming code
# i n c l u d e< s t d i o . h > i n tm a i n ( ) { c h a rc h ; p r i n t f ( " E n t e rac h a r a c t e r \ n " ) ;
www.programmingsimplified.com/c/source-code/c-program-check-vowel 1/4
8/7/13
s c a n f ( " % c " ,& c h ) ; i f( c h= =' a '| |c h= =' A '| |c h= =' e '| |c h= =' E '| |c h= =' i '| |c h= =' I '| |c h= = ' o '| |c h = = ' O '| |c h= =' u '| |c h= = ' U ' ) p r i n t f ( " % ci sav o w e l . \ n " ,c h ) ; e l s e p r i n t f ( " % ci sn o tav o w e l . \ n " ,c h ) ; r e t u r n0 ; }
Output of program:
8/7/13
c a s e' u ' : c a s e' U ' : p r i n t f ( " % ci sav o w e l . \ n " ,c h ) ; b r e a k ; d e f a u l t : p r i n t f ( " % ci sn o tav o w e l . \ n " ,c h ) ; } r e t u r n0 ; }
This function can also be used to check if a character is a consonant or not, if it's not a vowel then it will be a consonant, but make sure that the character is an alphabet not a special character.
www.programmingsimplified.com/c/source-code/c-program-check-vowel
3/4