Average value

Report a typo

In the topic, you've got acquainted with the Sum() function that counts the given arguments. Complete the function in such a way as to calculate an average value of the given numbers. In the input, you get three numbers, and you need to output their average value.

Tip: Use the len() function to determine the slice length.

Sample Input 1:

1 2 3

Sample Output 1:

2
Write a program in Go
package main

import "fmt"

func main() {
var num1, num2, num3 float32
fmt.Scan(&num1, ?, ?)

fmt.Println(Average(?))
}

func Average(numbers ?) float32 {
var sum float32
for _, num := range numbers {
sum += ?
}

return sum / float32(?)
}
___

Create a free account to access the full topic