
Program Control Flow
The statements in this section are used to control the flow of execution in a
program. The use of relational and logical operators with these control
statements and how to execute loops are also described.
→
if-else statement
•
Syntax
if (expression)
statement1;
[else
statement2;
]
•
Description
The if-else statement is a conditional statement. The block of statements
executed depends on the result of the condition. If the result of the
condition is nonzero, the block of its associated statements is executed.
Otherwise, the block of statements associated with the else statement is
executed if the else block exists. Note that the else statement and its
block of statements may not exist as it is optional.
•
Example
if (word_count > 128)
{
word_count=1
line++;
}
else
wor+;
→
for statement
•
Syntax
for
(initial-expression; condition-expression;
update-expression)statement;
The initial-expression is executed first and only once. It is used to assign
an initial value to a loop counter variable. This loop counter variable must
be declared before the for loop.
The condition-expression is evaluated prior to each execution of the
loop. If the condition-expression is evaluated to be nonzero, the state-
ment in the loop is executed. Otherwise, the loop exits and the first
statement encountered after the loop is executed next. The update-ex-
pression executes after the statement of the loop.
•
Description
The for statement is used to execute a statement or block of statements
repeatedly.
Chapter 9 Holtek C Language
95
Содержание 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 ...