Tuesday, 29 August 2017

Switch-Case()

Switch - Case ( ) 


Switch Case proclamation resembles an if explanation and it permit to us settle on choice from the quantity of decision. The information is just a single contention and that is any information sort and it check case alternative. At the point when case is accessible at that point execute case generally default proclamation will be executed.

grammar:-


switch( choice )
{

Statement 1;

Break;
}
case 1:
{

Statement 2;

Break;
}
case 2:
{

Statement 3;

Break;
}
case n:
{

Statement 4;

Break;
}
default:
{

Default - Statement 5;

Break;
}

Example Programme of If - Else if ( ) Statements:-


#include<stdio.h>
#include<conio.h>
void main ( )
{
int choice ;
clrscr ( );
printf ( "Enter the Vowel letters\n");
scanf ( "%d" , choice );
switch ( choice )
{
case 'a' :
{
printf ( "\nYour entered letter is Vowel" );
break ;
}
case 'e' :
{
printf ( "\nYour entered letter is Vowel" );
break ;
}
case 'i' :
{
printf ( "\nYour entered letter is Vowel" );
break ;
}
case 'o' :
{
printf ( "\nYour entered letter is Vowel" );
break ;
}
case 'u' :
{
printf ( "\nYour entered letter is Vowel" );
break ;
}
default:
{
printf ( "\nYour entered letter is Not Vowel" );
break ;
}
}
getch ( );
}
OUTPUT:-

Output
Enter the Vowel letters
a
Your entered letter is Vowel

No comments:

Post a Comment