FAQs Swift-5

Minimum of two numbers Swift 5

Advertisements

Minimum of two numbers Swift 5 will be explained here with its method. Minimum of two numbers means smallest value among given numbers. Calculating minimum number from two numbers is very basic thing which is commonly is used in programming so their are predefined methods for it. In swift also there is predefined method for calculating minimum of two numbers.

How to Calculate Minimum of two numbers Swift 5

To find the minimum of two numbers, either both integer or both floating point, use the min() function. For example:

let firstNumber = 10
let secondNumber = 105
let smallestNumber = min(firstNumber, secondNumber)
Print ("Smallest Number = \(smallestNumber)")

Output of Code : Smallest Number = 10

Leave a Comment