Compute the Average

  • + 0 comments

    (easy solution is here : and if you are fail in one test and pass 5 test it is because you are not useing %0.3f .else use this bigner code. :)

    read n
    result=0
    for((i=0;i<$n;i++))
    do
        read num
        result=$(echo " $result + $num " |bc)
    done
    r=$(echo "$result / $n" | bc -l)
    printf "%0.3f" "$r"