Skip to content

Instantly share code, notes, and snippets.

@TheMuellenator
Last active July 14, 2024 03:49
Show Gist options
  • Save TheMuellenator/83294ef2c2f606f146e51f4c4e547cab to your computer and use it in GitHub Desktop.
Save TheMuellenator/83294ef2c2f606f146e51f4c4e547cab to your computer and use it in GitHub Desktop.
iOS repl.it - Functions 2 Challenge Solution
//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()
@fhfournier
Copy link

Yeee im not crazy 🥳 this is an error inside unit test #2 @TheMuellenator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment