Write a program to Enter a character from keyboard and check the character is vowel or not by using 2 methods:
- switch statement
- else-if statement
1. By using switch statement:
#include<stdio.h>
#include<conio.h>
void main()
{
char k; // declaration of character variable k
clrscr();
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 Response to "C Program: Check the Character Vowel or Not by using switch Statement"
Post a Comment