#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;
}
}switch (expression) {
case constant1:
// statements
break;
case constant2:
// statements
break;
default:
// default statements
}int i;
switch (i){
case 1:
//The Proccess you want to be executed
break;
case 2:
//The Proccess you want to be executed
break;
default:
break;
}function whatToDrink(time){
var drink ;
switch (time) {
case "morning":
drink = "Tea";
break;
case "evening":
drink = "Shake";
break;
default:
drink="Water";
}
return drink;
}
console.log(whatToDrink("morning")) //Tea
console.log(whatToDrink("evening")) //Shake
console.log(whatToDrink("night")) //Water
console.log(whatToDrink("daytime")) //Waterswitch (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
}switch (variable or an integer expression)
{
case constant:
//C Statements
;
case constant:
//C Statements
;
default:
//C Statements
;
}