You are viewing a single comment's thread. Return to all comments →
Beware of spacing. For example:
read n for i in $(seq 1 $n); do read num sum=$((sum + num)) done printf "%.3f" $(echo "$sum/$n" | bc -l)
read n for i in $(seq 1 $n); do read num sum = $((sum + num)) done printf "%.3f" $(echo "$sum/$n" | bc -l)
The codes above produce different outputs. The first one is correct. p/s: Don't make the same mistake like me.
Seems like cookies are disabled on this browser, please enable them to open this website
Compute the Average
You are viewing a single comment's thread. Return to all comments →
Beware of spacing. For example:
The codes above produce different outputs. The first one is correct. p/s: Don't make the same mistake like me.