switch code block. Please understand that if a break does not
appear, execution falls-through to execute code in subsequent
cases
. For example,
switch(x) {
case 0 : printf(“A, “);
case 1: printf(“B, “); break;
default: printf(“C”);
}
Herein, a value of 0 for x would cause output of “A, B,”.
Also understand that most of the errors that occur when we work with switch structures
seem to be related to forgetting about fall-through. Therefore, we must always carefully check
for the
break statements
whenever we write a program using a
switch statement.
The block of
code associated with
each case
can be as simple as a single statement or it can be hundreds of lines
of code. Moreover, this code block can have another
Do'stlaringiz bilan baham: |