Switch-case statement
Switch is a conditional statement which will be used to select one set of statements from more than two alternative set of statements from more than two alternative sets of statements. Such a selection can be made using series of if-else statements also but that would make the understandability of program difficult.
Syntax:
switch(expression)
{ case value1: //statements
break;
case value2: //statements
break;
.
.
.
case valuen: //statements
break;
default: //statements
break;
}
--> switch, case, default, break are keywords.
--> Expression should not be of float or double type, but of int or char type.
--> value1,value2