Using swift programming
import UIKit
var str = "Hello, playground"
func ls(array: [Int]) -> (large: Int, small: Int)//function
{
var lar = array[0] // array of large number
var sma = array[0] // array of small number
let num = 0 // check odd or even
for i in array[1..<array.count] {
if i < sma && num % 2 == 0 {
sma = i
}else
if (i > lar) {
lar = i
} else
if num % 2 == 0 {
print("this is an even number")
} else
{
print("this is an odd number")
}
}
return (lar, sma)
}
let num = ls(array: [40,12,-5,78,98])
print("Largest number is: \(num.large ) \("\n") smallest number is: \( num.small)")