Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //swift
- //get average of variable number or arguments
- func averageOfArguments(args: Int...) -> Int {
- var sum = 0
- var avg = 0
- for a in args {
- sum += a
- }
- avg = sum / countElements(args)
- return avg
- }
- averageOfArguments(10,11,12,13,14)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement