You are currently viewing our forum as a guest which gives you limited access.
Membership is absolutely FREE and registration is FAST & SIMPLE so please, Register Today and join one of the friendliest communities on the net!

If you have any problems with the registration process or your account login, please contact us.

The switch and case keywords evaluate an expression and execute any statement associated with a constant expression whose value matches the initial expression.
If there is no match with a constant expression, the statement associated with the default keyword is executed. If the default keyword is not used, control passes to the statement following the switch block.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The condition of a switch statement is a value. The case says that if it has the value of whatever is after that case then do whatever follows the colon. 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. In this case, break prevents the program from falling through and executing the code in all the other case statements. An important thing to note about the switch statement is that the case values may only be constant integral expressions.

__________________To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. || To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. ||To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.||To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Its like a simple form of if else loop or simply saying do this if its true or this or this or this.... Its syntax is simple so people tend to use it rather than if else.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The switch and case keywords evaluate expression and execute any statement associated with constant-expression whose value matches the initial expression. If there is no match with a constant expression, the statement associated with the default keyword is executed.

__________________To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The switch and case keywords evaluate expression and execute any statement associated with constant-expression whose value matches the initial expression. If there is no match with a constant expression, the statement associated with the default keyword is executed

__________________To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The switch and case keywords evaluate expression and execute any statement associated with constant-expression whose value matches the initial expression. If there is no match with a constant expression, the statement associated with the default keyword is executed.

__________________To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The switch and case keywords evaluate expression and execute any statement associated with constant-expression whose value matches the initial expression. If there is no match with a constant expression, the statement associated with the default keyword is executed.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The switch condition is executed once.The value of the condition is matched with each case.If there is a match, then that particular matched case code executes.

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. | To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. |To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

The body of a switch statement is known as a switch block. A statement in the switch block can be labeled with one or more case or default labels. The switch statement evaluates its expression, then executes all statements that follow the matching case label.

__________________To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. || To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. ||To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.||To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.