Difference between revisions of "Basic Pascal Tutorial/Chapter 3/REPEAT..UNTIL"

From Free Pascal wiki
Jump to navigationJump to search
Line 1: Line 1:
 
{{REPEAT..UNTIL}}
 
{{REPEAT..UNTIL}}
 +
{{TYNavigator|WHILE..DO|FOR..IN}}
  
 
REPEAT..UNTIL (author: Tao Yue, state: unchanged)
 
REPEAT..UNTIL (author: Tao Yue, state: unchanged)
Line 15: Line 16:
 
This loop is called a posttest loop because the condition is tested after the body of the loop executes. The <tt>REPEAT</tt> loop is useful when you want the loop to execute at least once, no matter what the starting value of the Boolean expression is.
 
This loop is called a posttest loop because the condition is tested after the body of the loop executes. The <tt>REPEAT</tt> loop is useful when you want the loop to execute at least once, no matter what the starting value of the Boolean expression is.
  
{|style=color-backgroud="white" cellspacing="20"
+
{{TYNavigator|WHILE..DO|FOR..IN}}
|[[WHILE..DO|previous]] 
 
|[[Contents|contents]]
 
|[[FOR..IN|next]]
 
|}
 

Revision as of 18:29, 2 February 2016

български (bg) English (en) français (fr) 日本語 (ja) 中文(中国大陆)‎ (zh_CN)

 ◄   ▲   ► 

REPEAT..UNTIL (author: Tao Yue, state: unchanged)

The posttest loop has the following format:

repeat
  statement1;
  statement2
until BooleanExpression;

In a repeat loop, compound statements are built-in -- you don't need to use begin-end. Also, the loop continues until the Boolean expression is TRUE, whereas the while loop continues until the Boolean expression is FALSE.

This loop is called a posttest loop because the condition is tested after the body of the loop executes. The REPEAT loop is useful when you want the loop to execute at least once, no matter what the starting value of the Boolean expression is.

 ◄   ▲   ►