# Fresher Training—iOS Swift Day 1

630 views

## Today topic:

• Expressions, Variables & Constants
• Types & Operations
• Control Flow
• Functions
• Optionals
• Arrays, Dictionaries & Sets
• Collection Iteration with Closures
• Strings
• Structures
• Classes

## Exerices:

###### Exercise 01: Expressions, Variables & Constants

Declare four constants named x1, y1, x2 and y2 of type Double. These constants represent the 2-dimensional coordinates of two points. Calculate the distance between these two points and store the result in a constant named distance.

1 point

###### Exercise 02: Expressions, Variables & Constants

Given a number n, calculate the factorial of n.  (Example: 4 factorial is equal to 1 * 2 * 3 * 4.)

1 point

###### Exercise 03: Control Flow
1. Print 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0. Don’t use stride(from:by:to:)
2. What is Labeled statements? Using source code to explain.

1 point and 1.5 point

###### Exercise 03: Control Flow
1. Write a function that print log. This function can take a string as parameter, or multiple strings as paramsters. Return false if any string is empty.
2. (Optional) Write a function that calculate fibonancy sequence:  func fibonacci(_ number: Int) -> Int

1 point and bonus 0.5 point

###### Exercise 04: Collection Iteration with Closures

Define a dictionary with key is name: String and value is score: Double
Calculate sum of all score in dictionary

1 point

###### Exercise 05: Struct vs Class

Compare between struct and class

1.5 point

0 comment