import Foundation
func add(a: Int, b: Int) -> Int {
return a + b
}
while true {
print("enter a")
let a = Int(readLine() ?? "") ?? 0
print("enter b")
let b = Int(readLine() ?? "") ?? 0
let result = add(a: a, b: b)
print("the result is \(result)")
}
Last active
September 10, 2020 02:18
-
-
Save alexpaul/d1d8059c9eaa286112bca2ca7e4f810b to your computer and use it in GitHub Desktop.
Using `readLine()` to take in STDIN (input) from the user or command line and printing to the console (STDOUT).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment