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

Popular posts from this blog

Suppose you are given a square matrix of size n x n, write a program to determine if this is an identity matrix. 2D array

Program to create a multiplication table of a given number using while loop.

Program to find equal values using if statement in C++