C Programming (Loops) A Modern Approach K.N. King Ch 6 Loops

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

continue statement.....

makes it possible to skip part of a loop iteration without jumping out of the loop. Can only be used in loops.

break statements...

used to transfer control out of a switch stmt, and used to jump out of a while, do , or for loop.

A while statement won't terminate

...if the controlling expression always has a nonzero value. (infinite loop)

Loop

A statement whose job is to repeatedly execute some other statement(loop body)

compound statements

Can use brackets around multiple stmt's to treat as a single stmt. if (expression) statement can be if (expression) {statements}

Some facts about "for" stmts.....

In most cases can be replaced by equivalent while stmt. Doesn't need all 3 expressions. (keep semi's). If the first and third expressions are removed, it's just a while stmt in disguise, use a while instead.

comma operator

Lowest precedence, left associative Allows us to "glue" two expressions together in places where C requires a single expression.

Controlling expression

The statement inside the parentheses.

For

Used for loops that increment or decrement a counting variable.

Do

Used for loops whose controlling expression is tested after the loop body is executed.

While

Used for loops whose controlling expression is tested before the loop body is executed.

Comma operator

Used primarily in for statements.

The three iteration statements(Loops)

While, do and for

goto statement.....

allows a program to jump fro one statement to another provided the statement has a label, but rarely used because of availability of break and continue stmts.

Form of the do statement

do statement while (expression) ;

Form of the "for" statement

for (expr1 ; expr2 ; expr3) statement

Form of a goto statement...

goto identifier ; statement

Form of the while statement

while (expression) statement


Set pelajaran terkait

Marketing Chapters 8,9,10,11 Worksheets

View Set

Financial Accounting - Learning Objective #13

View Set

20-1: The heart is a four-chambered organ that pumps blood through the systemic and pulmonary circuits

View Set