switch statement is used to choose one of the blocks of code to get some output. Here in switch statement switch expression is evaluated once and compared with each “case” value.
Syntax:
`
switch(expression)
{
case 1 value :
// code goes here
break;
case 2 value :
// code goes here
break;
case 3 value :
// code goes here
break;
.
.
.
.
default: // optional
// default code goes here
}
`
Advantages of switch statement
- Easy to read than if-else statement
- More efficient than if-else statement 3. Easy to debug.
- Easy to maintain.
- Execution potential of switch statement is fast.


