Jump to content

[PASCAL] Repeat Until loop


CouldnoT
 Share

Recommended Posts

Repeat Until loop

 

 

Unlike the for loop which repeats for a specific number of cycles, the Repeat loop has no counter. It loops until a certain condition occurs (Returns True),

then it will go to the next statement after the loop. Example:

 

var
 Num : Integer;
begin
 repeat
 Write('Please input a number: ');
 Readln(Num);
 until Num <= 0;
 Writeln('Press any key to close');
 Readkey;
end. 

 

In the previous example, the program enters the loop, then it asks the user to enter a number. If the number is less than or equal to zero, it will exit the loop.

If the entered number is greater than zero, the loop will continue.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.