Programming instructions

Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Switch Case 1
The switch-case command is a decision-making statement which chooses commands to run
from a list of separate “cases”. A single “switch” value is selected and evaluated, and different
sets of code are run based on which “case” the value matches.
Switch Case
switch(switch-value)
{
case 1st-value:
// match-1st-commands
break;
case 2nd-value:
// match-2nd-commands
break;
default:
// default-commands
}
Below is the pseudocode outline of a switch-case Statement.
case value
A possible match for the switch value. If this value matches
the switch value, the code immediately following it runs.
switch value
The value which be checked for a match with any cases.
break; command
Marks the end of each case’s command statements.
default case
If the switch value does not match any of the given case
values, the “default” case will run.
case commands
The commands that run if this case successfully matched
Go to Reference Links