Menu
Coddy logo textTech

Recap Challenge #1

Lesson 10 of 21 in Coddy's Slices and Maps in Golang course.

challenge icon

Challenge

Easy

Write a program that takes a number as input from the user, computes the sum of all numbers in the slice, divides the sum by the number entered by the user, and prints the result to the screen. The result should be of type float.

Try it yourself

package main

import (
	"fmt"
)

func main() {
    // Get Input From the User Define the Slice  Don't change this
	var num int
	fmt.Scan(&num)
	numbers := []int{14, 200, 390, 400, 500}
	// Sum of all element
	
	
	// Divides the sum by the number entered by the user
	result := ? 
	// Print the result to the screen
	fmt.Println("Result:", result)
}	

All lessons in Slices and Maps in Golang