Monday, June 18, 2012

To check whether the entered character is vowel or not, using Switch statement


/* To check whether the entered character is vowel or not, using Switch statement */

#include<stdio.h>

#include<conio.h>

void main()

{

  char ch;

  clrscr();

  printf("\nEnter an alphabet: ");

  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!",ch);

      break;

    default:

      printf("%c is NOT a Vowel!",ch);

  }

  getch();

}

 

OUTPUT-1

Enter an alphabet: A

A is a Vowel!

 

OUTPUT-2

Enter an alphabet: d

d is NOT a Vowel!

 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.