Switch Case

Important rules of switch case :

Duplicate case values not allowed.
Case value must be the same data type as the variable in the switch.
Case value must be a constant or should not be variables.
The break statement is used inside the switch to terminate a statement sequence.
The default statement is optional.

switch(expression)
{
// case statements
// values must be of same type of expression
case value1 :
// Statements
break; // break is optional

case value2 :
// Statements
break; // break is optional

// No break is needed in the default case.
default :
// Statements
}