To find the minimum of two numbers in Swift, you can use the built-in min
function.
In this example,
num1
and num2
with specific values.min
function to find the minimum of num1
and num2
.min
function returns the smaller of the two values.import Foundation
let num1 = 5
let num2 = 10
let minimum = min(num1, num2)
print("The minimum of \(num1) and \(num2) is: \(minimum)")
The minimum of 5 and 10 is: 5
In this example,
num1
and num2
with specific values.min
function to find the minimum of num1
and num2
.min
function returns the smaller of the two values.import Foundation
let num1 = 15.5
let num2 = 10.3
let minimum = min(num1, num2)
print("The minimum of \(num1) and \(num2) is: \(minimum)")
The minimum of 15.5 and 10.3 is: 10.3
In this tutorial, we learned How to find the Minimum of Two Numbers in Swift language with well detailed examples.