You are viewing a single comment's thread. Return to all comments →
This does not work when using test case: 1 1 1 1 1
Additionally, the input format should only read N lines through.
read n arr=($(cat)) i=0 total=0 while [ $i -lt $n ]; do total=$(($total + ${arr[$i]})) (( i++ )) done printf "%.3f" $(echo "$total/$n" | bc -l)
Compute the Average
You are viewing a single comment's thread. Return to all comments →
This does not work when using test case: 1 1 1 1 1
Additionally, the input format should only read N lines through.