101
C-Control Pro Mega Series
corresponding to the value of the Expression and will continue the program from there. If no constant
corresponds to the value of the expression the switch construct will be left.
If a default is defined within a switch instruction then the instructions after default will be executed
if no constant corresponding to the value of the instruction has been found.
Example:
switch(a+2)
{
case 1:
b=b*2;
break;
case 5*5:
b=b+2;
break;
case 100&0xf:
b=b/c;
break;
default:
b=b+2;
}
break Instruction
A break will leave the switch instruction. If break is left out ahead of case then the instruction will
be executed even when a jump to the preceeding case does take place:
switch(a)
{
case 1:
a++;
case 2:
a++;
case 3:
a++;
}
In this example all three "a++" instructions are executed if a equals
5.2.6.7
while
With a while instruction the instructions can depending on a condition be repeated in a loop.
while( Expression ) Instruction;
At first the Expression is evaluated. If the result is unequal
// is also executed at a value of a==1
// is also executed at a value of a==1 or a==2
1.
0
then the Expression is executed. After
© 2008 Conrad Electronic
Need help?
Do you have a question about the C-Control Pro Mega Series and is the answer not in the manual?
Questions and answers