V
V
v- death2015-08-13 14:03:54
go
v- death, 2015-08-13 14:03:54

Why is the function argument not being passed?

Hello. I learn the basics.
Here is the code

package main

import "fmt"



func xses(x) float64 {

       var total float64 = 0
       for i:=0; i < len(x); i++ {
       	total += x[i]
       }
     return  total / float64(len(x)) 
}

func main() {
       
    x := [5]float64{ 
       98, 
       93, 
       77, 
       82, 
       83,
     }
fmt.Println(xses(x))

}

As a result, when compiled, it gives
# command-line-arguments
./main.go:7: undefined: x
./main.go:9: undefined: x
./main.go:10: undefined: x
./main.go:12: undefined: x

Thanks in advance

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2015-08-13
@vGrabko99

https://play.golang.org/p/huTRwNGkFr

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question