Javatpoint Logo
Javatpoint Logo

Control statementsin Loop

Control statements are used in loop to change execution from its normal sequence. When the execution leaves the scope all the already created objects which are created automatically in that scope are destroyed.

A list of control statements supported in Swift 4:


Continue Statement

Swift 4 continue statement is used to stop currently executing statement and start again at the beginning of the next iteration through the loop. The continue statement is used with for loop, while loop and do... while loop.

With 'for' loop, the continue statement tests the conditions and increments the portions of the loop to execute.

With 'while' and 'do...while' loops, the continue statement passes the program control to the conditional tests.

Syntax:

The syntax of the continue statement for the Swift 4 loops is as follow:

Flow diagram of Swift 4 Continue statement

Swift Continue Statement

Example:

Output:

Value of index is 11
Value of index is 12
Value of index is 13
Value of index is 14
Value of index is 15
Value of index is 16
Value of index is 17
Value of index is 18
Value of index is 19
Value of index is 20
Value of index is 21
Value of index is 22
Value of index is 23
Value of index is 24
Value of index is 25
Value of index is 26
Value of index is 27
Value of index is 28
Value of index is 29
Value of index is 30





Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA