Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AhmedMenaim/16c1bbf30918dcee713238aaae4bddaa to your computer and use it in GitHub Desktop.
Save AhmedMenaim/16c1bbf30918dcee713238aaae4bddaa to your computer and use it in GitHub Desktop.
Menaim Academy - Swift Course - Operators Part I
import Foundation
// MARK: - Assignment Operator =
var a = 15
var b = 5
// MARK: - Arithmetic Operators + - * /
print(a+b)
print(a-b)
print(a*b)
print(a/b)
// MARK: - Remainder Operator %
let c = 4 // -> Int without .5756
print(a/c) // -> 15 / 4 = 3 -> % = 15 - (3*4) = 15 - 12 = 3
print(a%c)
let firstNumber = 5
let secondNumber = 2
print(firstNumber / secondNumber) // -> 5 / 2 = 2 -> % = 5 - (2 * 2) = 1
print(firstNumber % secondNumber)
// MARK: - Unary Minus Operator
//a = -a // = -15
//print(a)
//print(-a) // - * - = +
// MARK: - Unary Plus Operator
a = +a // - * + = -
// MARK: - Compound Assignment Operators
a = a + 5 // Add 5 on a and store it in a -> 20
a += 5 // a -= 5 // 25
a -= 5
a += b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment