Program to check vowel using switch statement

11 months ago Admin 0

Check vowel using switch statement

This article illustrates the concept how to check vowel using switch statement in c/c++.

check vowel using switch statement

Here is the source code and output of both the programs.

C Programming language

Program


#include<stdio.h>
#include<conio.h>
void main()
{
 char ch;
 clrscr();
 printf("Input a character:- ");
 scanf("%s",&ch);
 switch(ch)
  {
   case'a':
   case'e':
   case'i':
   case'o':
   case'u':
   case'A':
   case'E':
   case'I':
   case'O':
   case'U':
    printf("Entered character is a vowel");
    break;
   default:
    printf("Entered character is not vowel");
  }
getch();
}

After successfully compiling and executing the above C program,output is:-

check vowel using switch statement


C++ Programming language

Program


#include
#include
void main()
{
 clrscr();
 char ch;
 cout<<"Input a character:- ";
 cin>>ch;
 switch(ch)
  {
   case'a':
   case'e':
   case'i':
   case'o':
   case'u':
   case'A':
   case'E':
   case'I':
   case'O':
   case'U':
    cout<<"Entered character is a vowel";
    break;
   default:
    cout<<"Entered character is not vowel";
  }
getch();
}

After successfully compiling and executing the above C++ program,output is:-

check vowel using switch statement


Comment below if you are facing any problem or you find any error in the above program and also subscribe to our newsletter for more updates.


Read more c/c++ Programs published by snapcout:-

Program to find sum of individual digits of entered number
rogram to find hcf of two numbers
Program to find lcm of two numbers
Program to find maximum of given number
Program to count number of digit in an integer


About article

Written By:- Admin

Published on:- 15/09/2018

Published By:- Snapcout


Don't forget to share the article if you like it:-