Recent Posts

9-latest-250px-course

Write a C program to Check Whether a Character is Vowel or Consonant

Write a C program to Check Whether a Character is Vowel or Consonant



Program:-     

Method : 1


#include <stdio.h>

void vowel_or_consonant(char ch)

{

if ((ch == ‘a’ || ch == ‘e’ || ch == ‘i’ || ch == ‘o’ || ch == ‘u’) || (ch == ‘A’ || ch == ‘E’ || ch == ‘I’ || ch == ‘O’ || ch == ‘U’))

printf(“Vowel\n”);

else

printf(“Consonant\n”);

}

int main()

{

char ch;

printf(“\nInput a character : “);

scanf(” %c”,&ch);

printf(“\n%c is a “,ch);

vowel_or_consonant(ch);

return 0;

}

Output:-

....

Method : 2

#include <stdio.h>

void vowel_or_consonant(char ch)

{

switch(ch)

{

case ‘a’:

case ‘A’:

case ‘e’:

case ‘E’:

case ‘i’:

case ‘I’:

case ‘o’:

case ‘O’:

case ‘u’:

case ‘U’: printf(“Vowel\n”);

break;

default : printf(“Consonant\n”);

}

}

int main()

{

char ch;

printf(“\nInput a character : “);

scanf(” %c”,&ch);

printf(“\n%c is a “,ch);

vowel_or_consonant(ch);

return 0;

}

Output:-

....
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment