Switch Statement in C
Switch Case in C A switch statement allows equality checking of an attribute against a set of values. Each attribute is called a case, and for each switch case in C , the variable to be turned on is checked. With Switch statements, users can describe different statements for the differing values of a single variable in numerous cases. Syntax Here is the syntax of the switch statements in the C language: switch(expression) { case value1: //code to be executed; break; //optional case value2: //code to be executed; break; //optional ...... default: code that is be executed if all the cases are not matched; } For a switch statement − the following rules apply The term used in a switch statement in C must be of an integral or ...