Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Wednesday, March 11, 2015

What is switch statement ?

It is a multiway decision making statement. In switch statement we take a variable, the value of variable is compare with a list of case values and when the match is found than a statement block related with matching case is executed. Only one case value can be matched at a one switch statement. The variable can be integer or character.

Switch statement contain an else part known as default case, it executed when no match found. The default case is optional. At the end of case statements we use a break statement to terminate (exit) from the switch statement.
Syntax:
switch(variable)
{
case value1:       statement1;
                                ……………………
                                break;
………………
……………..
case valueN:      statement1;
                                ……………………….
                                break;
default:                                statement1;
                                ………………………
}



No comments:

Post a Comment