The switch variable is tested against a list of constants. When a match
is found, the statements with that constant are executed until a break
statement is encountered. If no break statement exists, execution flows
through the rest of the statements until the end of the switch routine. If
no match is found, the statements associated with the default case are
executed. The default case is optional.
•
Description
The if-else statement can be used to select between a pair of alternatives,
but becomes cumbersome when many alternatives exist. The switch
statement is an alternative multi-way decision method that evaluates if
an expression matches one of many alternatives, and branches accord-
ingly. It is equivalent to multiple if-else statements.
The switch statement’s limitation is that the switch variable must be
an integral data type, and can only be compared against constant values.
•
Example
for (i=j=0;i<10;i++)
{
switch (b[i])
{
case 0: goto outloop;
case 0
×
20:break;
default:
a[j]=b[i];
j++;
break;
}
}
outloop:
Functions
In the C language, all executable statements must reside within a function.
Before a function is used or called, it must be either defined or declared,
otherwise a warning message will be issued by the C compiler. Two syntax
forms, namely classic and modern, are supported for function declaration
and definition.
Classic form
return-type function-name (arg1, arg2,...)
var-type arg1;
var-type arg2;
HT-IDE User’s Guide
98
Содержание HT-IDE
Страница 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Страница 12: ...HT IDE User s Guide 2 ...
Страница 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Страница 24: ...HT IDE User s Guide 14 ...
Страница 70: ...HT IDE User s Guide 60 ...
Страница 76: ...HT IDE User s Guide 66 ...
Страница 92: ...HT IDE User s Guide 82 ...
Страница 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Страница 94: ...HT IDE User s Guide 84 ...
Страница 148: ...HT IDE User s Guide 138 ...
Страница 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Страница 154: ...HT IDE User s Guide 144 ...
Страница 192: ...HT IDE User s Guide 182 ...
Страница 194: ...HT IDE User s Guide 184 ...
Страница 218: ...HT IDE User s Guide 208 ...
Страница 235: ...P a r t V Appendix Part V Appendix 225 ...
Страница 236: ...HT IDE User s Guide 226 ...
Страница 250: ...HT IDE User s Guide 240 ...