Share

BREAK statement in a SWITCH statement

The BREAK statement exits the SWITCH statement.

The basic control structure is:

SWITCH variable {
    CASE (constant_A)
        Commands A
        BREAK
    CASE (constant_B)
        Commands B
        BREAK
    DEFAULT
        Commands C
}
Commands D

If condition_A is true then Commands A are executed followed by Commands D.

Note: Remember, if there is no break statements then commands A, B, C, and D are carried out.

If condition_B is true then Commands B are executed followed by Commands D.

If condition_A and condition_B are false then Commands C are executed followed by Commands D.

image

Was this information helpful?