switch y case en c code example
Example 1: switch case c
switch (expression) {
case constant1:
// statements
break;
case constant2:
// statements
break;
default:
// default statements
}
Example 2: switch c
switch (n)
{
case 1: // code to be executed if n = 1;
break;
case 2: // code to be executed if n = 2;
break;
default: // code to be executed if n doesn't match any cases
}