17.02.2015 Views

CCS C Compiler Manual PCB / PCM / PCH

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Statements<br />

The expression is evaluated and the statement is executed until it becomes false in which case<br />

the execution continues after the statement.<br />

Example:<br />

while (get_rtcc()!=0)<br />

putc('n');<br />

Also See: Statements<br />

do-while<br />

do-while: Differs from while and for loop in that the termination<br />

condition is checked at the bottom of the loop rather than at the<br />

top and so the body of the loop is always executed at least once.<br />

The syntax is:<br />

do<br />

statement<br />

while (expr);<br />

The statement is executed; the expr is evaluated. If true, the<br />

same is repeated and when it becomes false the loop terminates.<br />

Also See: Statements , While<br />

for<br />

For is also used as a loop/iteration statement.<br />

The syntax is:<br />

for (expr1;expr2;expr3)<br />

statement<br />

The expressions are loop control statements. expr1 is the<br />

initialization, expr2 is the termination check and expr3 is reinitialization.<br />

Any of them can be omitted.<br />

Example:<br />

for (i=1;i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!