You can subtract two numbers in Swift by using the -
operator. Here's an example:
main.swift80 chars4 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