98
Compiler
© 2008 Conrad Electronic
break Instruction
A break instruction will leave the loop and the program execution will start with the next instruction
after the do .. while loop.
continue Instruction
When executing continue within a loop there will immediately be a new calculation of the
Expression. Depending on the result the loop will be repeated at unequal
0
. At a result of
0
the loop
will be terminated.
Example:
do
{
a++;
if(a>
10
) break;
// will terminate loop
} while(
1
);
// endless loop
5.2.6.3
for
A for loop is normally used to program a definite number of loop runs.
for(Instruction1; Expression; Instruction2) Instruction3;
At first Instruction1 will be executed which normally contains an initialization. Following the
evaluation of the Expression takes place. If the Expression is unequal
0
Instruction2 and Instruction3
will be executed and the loop will repeat itself. When Expression reaches the value
0
the loop will be
terminated. As with other loop types at Instruction3 an
Instruction Block
can be used instead of a
single instruction.
for(i=
0
;i<
10
;i++)
{
if(i>a) a=i;
a--;
}
It must be observed that variable i will within the loop run through values 0 through 9 rather than 1
through 10!
If a loop needs to be programmed with a different step width Instruction2 needs to be modified
accordingly:
for(i=
0
;i<
100
;i=i+
3
)
// variable i does now increment in steps to 3
{
a=
5
*i;
}
Summary of Contents for C-Control Pro Mega Series
Page 1: ... 2008 Conrad Electronic C Control Pro Mega Series ...
Page 9: ...VIII Inhalt 2008 Conrad Electronic ...
Page 10: ...Part 1 ...
Page 17: ...Part 2 ...
Page 23: ...Part 3 ...
Page 41: ...32 Hardware 2008 Conrad Electronic 3 3 5 3 Component Parts Plan ...
Page 57: ...48 Hardware 2008 Conrad Electronic 3 4 5 3 Component Parts Plan ...
Page 58: ...Part 4 ...
Page 91: ...82 IDE 2008 Conrad Electronic ...
Page 92: ...Part 5 ...
Page 135: ...126 Compiler 2008 Conrad Electronic 31 1F US 63 3F 95 5F _ 127 7F DEL ...
Page 136: ...Part 6 ...
Page 231: ...Part 7 ...
Page 240: ......