In C, the switch statement allows branching based on the value of an expression. The syntax is as follows:
expression
is evaluated, and the control is transferred to the matchingcase
.- The
break
statement exits the switch block after the case code runs. - The
default
case is optional and executes if no case matches.
Ensure break
is used to avoid fall-through.