A switch
statement is a control flow mechanism in C used to execute one of many code blocks based on the value of a variable. It evaluates an expression and compares its value with multiple case
labels. When a match is found, the corresponding block of code is executed. The break
statement is used to exit the switch after the matching case is executed. If no match is found, the default
case is executed, if provided. Example:
switch (variable) {
case 1:
// code
break;
case 2:
// code
break;
default:
// code
}