Conditional Statements in Swift- If statement

Swift provides two ways to add conditional branches to your code, known as the if statement and the switch statement. Typically, you use the if statement to evaluate simple conditions with only a few possible outcomes. In its simplest form, the if statement has a single if condition. It executes a set of statements only if that condition is true. The syntax is …

Conditional Loop in Swift- Do-While

The other variation of the while loop, known as the do–while loop, performs a single pass through the loop block first, before considering the loop’s condition. It then continues to repeat the loop until the condition isfalse. Here’s the syntax of a do–while loop:

Here’s the Snakes and Ladders example again, written as a do–while loop rather than a …