EmbLogic's Blog

Switch Case

Rules for using Switch Case in C Programming :

1. Case Label must be unique.

2.Case Label must ends with colon.

3.Case Label must have constants/ constant expression.

4.Case Label must be of Integral Type(Integer, Character).

5.Case Label should not be ‘ Floating Point Number ‘.

6.Switch case should have at most one default Label.

7.Default Label is optional.

8.Default can be placed anywhere in the switch.

9.Break statement takes control out of the switch.

10.Two or more cases may share one break statement.

11.Nesting(switch within switch) is allowed.

12.Relational operators are not allowed in switch statement.

13.Macro Identifier are allowed as Switch Case Label.

14.Constant Variable is allowed in switch case statement.

15.Empty switch case is allowed.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>