Flow control: switch
For multiple branching
Successively tests the value of an expression against a list of int or char constants
Executes a statement iff a match is found
Default executed if no match is found
switch(EXPRESSION){
case CONSTANT 1:
STATMENT SEQUENCE
break;
...
case CONSTANT N:
STATMENT SEQUENCE
break;
default
STATMENT SEQUENCE
}
Previous slide
Next slide
Back to first slide
View graphic version