Switch:
Another way to control the flow of your programs is with something called a switch
statement. A switch statement gives you the option to test for a range of values for
your variables. They can be used instead of long, complex if … else if statements. The
structure of the switch statement is this:
switch ( variable_to_test ) {
case value:
code_here;
break;
case value:
code_here;
break;
default:
values_not_caught_above;
}
No comments:
Post a Comment