Saturday 22 June 2013

Write a C program which recognizes a letter whether it is a vowel or consonant. Use switch statement in your program.



Code:

#include<stdio.h>
void main()
{
 char ch;
 printf("Enter a single character:\n");
 scanf("%c",&ch);
 if((ch=='a')||(ch=='e')||(ch=='i')||(ch=='o')||(ch=='u')||(ch=='A')||(ch=='E')||(ch=='I')||(ch=='O')||(ch=='U'))
 {
  printf("The given Character '%c' is a Vowel\n ",ch);
 }
 else
 {
  printf("The given Character '%c' is a Consonant\n ",ch);
 }
getch();
}

No comments:

Post a Comment