Page 46 - Modular_V1.1_Flipbook
P. 46
[statements;
break;]
::
default:
statements;
}
In the preceding syntax, you can see that the switch statement uses case statement multiple
times to evaluate multiple expressions. If none of the expressions evaluates to true, then the
default case gets executed. The break statement is used in each case to terminate the execution
when the case is matched.
Program 6: To check whether the entered character is vowel or consonant.
#include<iostream.h>
#include<conio.h>
void main()
{
char ch;
cout<<"Enter a character: ";
cin>>ch;
switch (ch)
{
case 'A':
cout<<"Entered character is vowel";
break;
case 'a':
cout<<"Entered character is vowel";
break;
case 'E':
cout<<"Entered character is vowel";
break;
case 'e':
cout<<"Entered character is vowel";
break;
case 'I':
cout<<"Entered character is vowel";
break;
case 'i':
cout<<"Entered character is vowel";
break;
case 'O':
cout<<"Entered character is vowel";
44 Touchpad MODULAR (Version 1.1)-X

