switch evaluates an integer expression and jumps to a matching case. break exits the switch. The default branch handles values without a matching case. Use a switch when cases are discrete values, rather than numeric ranges.
Read the example
The complete program appears below. Read it first, predict the output, then run it.
Expected output
Repair status
Practise
Add choice 3 for billing, then test an unsupported choice.
Common mistake
Without break, execution continues into the next case unless an earlier return exits the function.