Instructions
186Compiler
© 2013 Conrad Electronic
case 2:
a++; // is also executed at a value of a==1
case 3:
a++; // is also executed at a value of a==1 or a==2
}
In this example all three "a++" instructions are executed if a equals 1.
4.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 0 then the Expression is executed. After
that the Expression is again calculated and the entire procedure will constantly be repeated until the
Expression takes on the value 0. An Instruction Block can be defined instead of a single instruction.
Example:
while(a<10) a=a+2;
while(a)
{
a=a*2;
x=a;
}
break Instruction
If a break is executed within the loop then the loop will be left and the program execution starts with
the next instruction after the while loop.
continue Instruction
An execution of continue within a loop will immediately initialize a new calculation of the Expres-
sion. Depending on the result the loop will be repeated at unequal 0. A result of 0 will terminate the
loop.
Example:
while(1) // endless loop
{
a++;
if(a>10) break; // will terminate the loop
}