Lecture 8 Looping Statements
Lecture 8 Looping Statements
Lecture 8
PROGRAMMING 1
• When the condition becomes false, program control passes to the line after
the loop code.
2. Condition is checked. If it is true, the loop continues; otherwise, the loop ends,
and statement is skipped, going directly to step 5.
5. The loop ends: execution continues by the next statement after it.
• They can be left empty, but in all cases the semicolon signs between
them are required.
• Unfortunately, these are not statements, but rather, simple expressions, and
thus cannot be replaced by a block.
• As expressions, they can, however, make use of the comma operator (,): This
operator is an expression separator, and can separate multiple expressions
where only one is generally expected.
• For example, using it, it would be possible for a for loop to handle two counter
variables, initializing and increasing both:
for ( n=0, i=100 ; n!=i ; ++n, --i ) { // whatever here... }
Engr. Jenn P. Cabale Lecture 8 - LOOPING STATEMENTS 16
Jump Statements
• Jump statements allow altering the flow of a program by performing
jumps to specific locations.