why use switch case in c code example
Example 1: switch case c
switch (expression) {
case constant1:
// statements
break;
case constant2:
// statements
break;
default:
// default statements
}
Example 2: switch case in c syntax
switch( expression )
{
case value-1:
Block-1;
Break;
case value-2:
Block-2;
Break;
case value-n:
Block-n;
Break;
default:
Block-1;
Break;
}
Statement-x;