day 3 Flashcards
if else
if { // code to execute } else { // code to execute }
else if
if firstCondition { codeToExecuteIfTrue } else if secondCondition { codeToExecuteIfTrue } else if thirdCondition { codeToExecuteIfTrue } else { codeToExecuteIfEverythingElseIsFalse }
switch
switch month { case 1: print(“January”) case 2: print(“February”) // … }
range
1…10
for loops
for n in 1…5 { print(n) }
while loop
var index = 10 while index < 20 { print( “Value of index is (index)”) index = index + 1 }
break
var index = 10 repeat { index = index + 1 if( index == 15 ){ break } print( “Value of index is (index)”) } while index < 20
repeat-while example
var sum = 2 repeat{print(sum)sum = sum + 2} while sum < 10
repeat while flowchart