Switch Statement in C

A switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being switched on is checked for each switch case.
Syntax
The syntax for a switch statement in C programming language is as follows −

switch(expression){    
case value1:    
 //code to be executed;    
 break; //optional  
case value2:    
 //code to be executed;    
 break; //optional  
......    
    
default:     
 code to be executed if all cases are not matched;    
}    

Posted on by