package main import "fmt" func main(){ sum:=0.0 avg:=0.0 xs:="123243" switch len(xs){ case 0: avg=0 default: for _,v:=range xs{ sum+=float64(v) } avg=sum/float64(len(xs)) } fmt.Println(float64(len(xs))) fmt.Println(sum) _=avg; fmt.Println(avg) }
package main import "fmt" func main(){ sum:=0.0 avg:=0.0 xs:="123243" switch len(xs){ case 0: avg=0 default: for _,v:=range xs{ sum+=float64(v) } avg=sum/float64(len(xs)) } fmt.Println(float64(len(xs))) fmt.Println(sum) _=avg; fmt.Println(avg) }