subtract two numbers in swift

You can subtract two numbers in Swift by using the - operator. Here's an example:

main.swift
let num1 = 10
let num2 = 5
let difference = num1 - num2 // difference will be 5
80 chars
4 lines

In this example, we're declaring two variables num1 and num2 with the values of 10 and 5, respectively. We then subtract num2 from num1 using the - operator and store the result in the difference variable. The difference variable will have a value of 5, which is the result of subtracting num2 from num1.

gistlibby LogSnag