** switch Statement :-
A switch Statement is used when there is a choice as to which code to execute , depending on the value of a constant expression. Different cases are presented, and are checked one by one to see if one case matches the value of the constant Expression. If a case matches, its block of code is executed. If none of the cases match, the default code is executed.
- Syntax of the switch statement :-
switch(integer or character expression)
{
case constant_1:
statement sequence 1;
break;
case constant_2:
statement sequence 2;
break;
case constant_n:
statement sequence ;
break;
default :
statement sequence ; //end of switch statement
}
- The Flowchart of switch Statement :