Program to determine the vowels through switch statement.
Using Visual Studio 2015
===========================================================================
#include<iostream>
using namespace std;
#include<conio.h>
void main()
{
char letter;
cout<<"enter a letter=";
cin>>letter;
switch (letter)
{
case 'a':
case 'A':
case 'e':
case 'E':
case 'i':
case 'I':
case 'o':
case 'O':
case 'u':
case 'U':
cout<<"\nYou have entered a vowel.";
break;
default:
cout<<"Invalid input";
break;
}
_getche();
}
=========================================================================
To determine vowels is much easier through 'Switch statement' than 'if else if' . If you have any query, contact.
Comments
Post a Comment