Switch Statement |
||||
42 views
The C Switch case statements are a substitute for long if statements that compare a variable to several values. These values can be int ,char or any other types which allows multiple choice of a selection of items at one level of a conditional where it is a far neater way of writing multiple if statements: Syntax : switch (expression) { case itemn: } The expression of a switch statement is a value. The case says that if above expression has the value whatever is after that case then do whatever follows the statements. The break is used to break out of the case statements. Break is a keyword that breaks out of the code block, usually surrounded by braces, which it is in. Example : switch (Days) { statements; break; } { statements; break; } case `tuesday’: { statements; break; } case `wednesday’: { statements; break; } case `thursday’: { statements; break; } case `friday’: { statements; break; } statement; |
| « Css Introduction | Css Syntax » |
| Posted on Thursday, June 12th, 2008 at 5:57 pm under C For Beginners | RSS 2.0 Feed | |