Upload
hardik-gupta
View
88
Download
0
Embed Size (px)
Citation preview
Iteration Statements
What you’ll learn:
1.while loop
2.do – while loop
3.for loop
4.Jump Statements
What are iteration statements?
An iteration statement, or loop, is a way of repeating a statement, known as loop body, a number of times until some condition is satisfied.
We have following types of iteration statements in C: while loop
do-while loop
for loop
Set of instructions
conditionTrue
False
Iteration Statements
while loop
while loop
Syntax:
initialization;while (test_condition) { ...block of code... increment/decrement;}
loop bodyconditionTrue
False
exit from loop
instructions
Iteration Statements
do-while loop
do – while loop
Syntax:
initialization;do {
…block of code…increment/decrement;
} while (test_condition);
conditionTrue
Exit from loop
Loop body
False
Iteration Statements
for loop
for loop
Exit from loopconditionFalse
True
Loop body
initialization
Syntax:
for ( initialization; test_condition; update_expression ) {
…block of code…}
Update Expression
Jump Statements
What are jumping statements ?
What are jumping statements?
Jump statements can be used to modify the behavior of conditional and iterative statements.
Some jump statements provided by C are:o continueo breako gotoo return