Case Control Structure
Case Control Structure
The case control structure is implemented using a switch statement
Syntax:
Switch(integer expression)
{
case constant_1: Block of statements
case constant _2: Block of statements
case constant_3: Block of statements
..........................................................................
case constant_n: Block of statements
default:
Block of statements
}
The integer expression is evaluated first and then matched with each case. When the value of the expression matches one of the cases, the block of statements from that case will be executed, including the default block.
If no case is matched, then the default block will be executed.