Swift - Write program to write a function that takes in a variable number of Int parameters and returns the sum of all the arguments.

Requirements

Write a function that takes in a variable number of Int parameters and returns the sum of all the arguments.

Demo

func sum(nums: Int...) -> Int {
        var sum = 0
        for num in nums {
            sum += num//www  .  j a  va 2  s.  c  om
        }
        return sum
}

Related Exercise