Advertisement
Tariqul_Islam

Compute the Average

Aug 7th, 2020
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.13 KB | None | 0 0
  1. #!/bin/bash
  2. read n
  3. sum=0
  4. for ((i = 0; i < n; i++));
  5. do
  6. read a
  7. sum=$((sum + a))
  8. done
  9. printf "%.3f\n" `echo "$sum/$n" | bc -l`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement