Compute the Average

  • + 0 comments
    read input
    x=0
    i=0
    while [[ $i -lt $input ]]
    do
    read num
    x=$((x+num))
    i=$((i+1))
    done
    echo $(printf %.3f $(echo "scale=4;$x/$input"|bc -l))