Last active
July 14, 2024 03:49
-
-
Save TheMuellenator/83294ef2c2f606f146e51f4c4e547cab to your computer and use it in GitHub Desktop.
iOS repl.it - Functions 2 Challenge Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Don't change this code: | |
func calculator() { | |
let a = Int(readLine()!)! //First input | |
let b = Int(readLine()!)! //Second input | |
add(n1: a, n2: b) | |
subtract(n1: a, n2: b) | |
multiply(n1: a, n2: b) | |
divide(n1: a, n2: b) | |
} | |
//Write your code below this line to make the above function calls work. | |
func add(n1: Int, n2: Int) { | |
print(n1 + n2) | |
} | |
func subtract(n1: Int, n2: Int) { | |
print(n1 - n2) | |
} | |
func multiply(n1: Int, n2: Int) { | |
print(n1 * n2) | |
} | |
func divide(n1: Int, n2: Int) { | |
let decimalN1 = Double(n1) | |
let decimalN2 = Double(n2) | |
print(decimalN1 / decimalN2) | |
} | |
//Don't move or change this code: | |
calculator() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
func addation() {
print("(a + b)")
}
var a = 3
var b = 4
addation()
func subtraction() {
print("(a - b)")
}
var a = 3
var b = 4
subtraction()
func multiply()
{
var a = 3
var b = 4
print("(a * b)")
}
multiply()