Vowel / Consonant

C program to find character is vowel or not :

code

  #include<stdio.h>

#include<conio.h>

     void main()

{

    char ch;

    clrscr();

   printf(“Enter a character :\n”);

   scanf(“%c”, &ch);

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

{

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

}

  else

{

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

}

 getch();

}


output

Enter a character :

D

D is Consonant

 

 

 


C program to find character is vowel or not using switch case :

#include <stdio.h>

#include<conio.h>

void main()

{

char ch;

clrscr();

printf(“Enter a character :\n”);

scanf(“%c”, &ch);

  switch(ch)

{

   case ‘a’:

   case ‘A’:

   case ‘e’:

   case ‘E’:

   case ‘i’:

   case ‘I’:

   case ‘o’:

   case ‘O’:

    case ‘u’:

    case ‘U’:

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

      break;

      default:

      printf(“%c is Consonant.\n”, ch);

}

      getch();

}

 


output

Enter a character :

D

D is Consonant

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s