Switch statement :

when there are several options and we have to choose only one option from the available ones, we can use switch statement. Depending on the selected option, a particular task can be performed. A task represents one or more statements. 

Syntax: 

switch(expression) 

{

 case value-1: statement/block-1;

 break;

 case value-2: statement/block t-2; 

break; 

case value-3: statement/block -3;

 break;

 case value-4: statement/block -4;

 break;

 default: default- statement/block t; 

break; 


Rules for writing switch() statement 

1 : The expression in switch statement must be an integer value or a character constant. 

2 : No real numbers are used in an expression. 

3 : The default is optional and can be placed anywhere, but usually placed at end. 

4 : The case keyword must terminate with colon ( : ). 

5 : No two case constants are identical. 

6 : The case labels must be constants.