Conrad C-Control Pro Mega Series Manual page 109

Table of Contents

Advertisement

if(a==2) b++;
if(x==y) a=a+2;
else a=a-2;
An
Instruction Block
Examples:
if(x<y)
{
c++;
if(c==10) c=0;
}
else d--;
if(x>y)
{
a=b*5;
b--;
}
else
{
a=b*4;
y++;
}
5.2.6.6
switch
If depending on the value of an expression various commands should be executed a switch
instruction is an elegant solution:
switch( Expression )
{
case constant_1:
Instruction_1;
break;
case constant_2:
Instruction_2;
break;
.
.
case constant_n:
Instruction_n;
break;
default:
Instruction_0;
};
The value of the Expression is calculated. Then the program execution will jump to the constant
© 2008 Conrad Electronic
can be defined instead of a single instruction.
// default is optional
Compiler
100

Advertisement

Table of Contents
loading
Need help?

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

This manual is also suitable for:

C-control pro mega32C-control pro mega128

Table of Contents