Switch Statement in C
Last Updated Nov 4, 2015, 07:00:14 PM
Switch statement is mainly used when the program the has to chose a particular statement among many other statements.Syntax
Control passes to the statement whose case constant-expression matches the value of the switch ( expression ). The switch statement can include any number of case instances, but no two case constants within the same switch statement can have the same value. Execution of the statement body begins at the selected statement and proceeds until the end of the body or until a break statement transfers control out of the body.
Example of Switch Case in CTry It Now
- A single switch statement in c can have any no of case statements in it
- If the break statement encountered then the switch will terminates.
- Switch statement can have a default statement incase to execute as a default result.
Other Decision Making Topics you might want to learn
If Statement in C
If else Statement in C
Nested If Statement in C