Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: Report statistics

Given some numbers in an array, print out the total, the average, the minimum and the maximum values.

package main

import "fmt"

func main() {
	numbers := [...]int{2, 3, 5, -1, 1, 8}
	fmt.Println(numbers)

}

Expected output:

[2 3 5 -1 1 8]
Total: 18
Average: 3
Min: -1
Max: 8