Blogger templates

Pages

Monday, 23 April 2012

C Program: Check the Character Vowel or Not by using switch Statement

Vowels

Write a program to Enter a character from keyboard and check the character is vowel or not by using 2 methods:
  1. switch statement
  2. else-if statement

1. By using switch statement:
#include<stdio.h>
#include<conio.h>
void main()
{
char k;                                          // declaration of character variable k
clrscr();
printf("Enter the value of k:");

scanf("%d" ,&k);
switch(k)                                       // where k is variable
{
case a;                                          // value of k is a
printf(" Number is vowel");
break:
case e;                                          // value of k is e
printf(" Number is vowel");
break:
case i;                                           // value of k is i
printf(" Number is vowel");
break:
case o;                                           // value of k is o
printf(" Number is vowel");
break:
case u;                                           // value of k is u
printf(" Number is vowel");
break:
default:                                         // value of k is other than a, e, i, o, u
printf(" Number is not vowel");
break:
}
//  End of main()

Output:
Enter the value of k:
a
Number is vowel

Output:
Enter the value of k:
x
Number is not vowel




0 comments:

Post a Comment