Home » Swift repeat-while loop

Swift repeat-while loop

by Online Tutorials Library

Repeat While loop

The Repeat While loop is same as while loop but a difference that the body of repeat…while loop is executed once before the test expression is checked.

Syntax:

In this loop, the body of repeat while loop is executed once and after that testExpression is checked.

Flowchart of Repeat While loop

Swift Repeat while Statement

Example:

Output:

You have successfully completed level 0  You have successfully completed level 1  You have successfully completed level 2  You have successfully completed level 3  You have successfully completed level 4  You have successfully completed level 5  Terminated! outside of repeat while loop  

Next TopicSwift Strings

You may also like