c switch default code example
Example 1: switch statement in c
#include <stdio.h>
int main(void)
{
int a = 0;
switch(a)
{
case 1 :
statement("a = 1");
break;
case 2 :
printf("a = 2");
break;
default :
printf("a is neither 1 or 2");
break;
}
}
Example 2: c switch
int i;
switch (i){
case 1:
break;
case 2:
break;
default:
break;
}
Example 3: c switch case
switch (expression) {
case constant1:
break;
case constant2:
break;
default:
}
Example 4: c switch case example
switch (variable or an integer expression)
{
case constant:
;
case constant:
;
default:
;
}
Example 5: switch case c
switch(expression) {
case constant-expression :
statement(s);
break;
case constant-expression :
statement(s);
break;
default :
statement(s);
}