Pascal - Continue Statement
- Details
- Category: Chapter 2
- Published: Sunday, 14 April 2013 14:45
- Written by Sternas Stefanos
- Hits: 18759
The continue statement in Pascal works somewhat like the break statement. Instead of forcing termination, however, continue forces the next iteration of the loop to take place, skipping any code in between.
For the for-do loop, continue statement causes the conditional test and increment portions of the loop to execute. For the while-do and repeat...until loops, continue statement causes the program control passes to the conditional tests.
1. Syntax:
The syntax for a continue statement in Pascal is as follows:
continue;
2. Flow Diagram:
3. Example:
program exContinue; var a: integer; begin a :=10; (* repeat until loop execution *) repeat if( a =15)then begin (* skip the iteration *) a := a +1; continue; end; writeln('value of a: ', a); a := a+1; until( a =20); end.
When the above code is compiled and executed, it produces following result:
value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 16 value of a: 17 value of a: 18 value of a: 19