We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Linux Shell
- Bash
- Compute the Average
- Discussions
Compute the Average
Compute the Average
Sort by
recency
|
358 Discussions
|
Please Login in order to post a comment
!/bin/bash
read n sum=0
for (( i=0; i
Calculate and print average rounded to 3 decimal places
avg=sum / avg"
This problem is a great way to practice handling input, performing arithmetic operations, and formatting output in programming! 🖥️✨ Calculating the average and rounding it to three decimal places ensures precision, which is useful in real-world applications. Daman Games Online
readarray -t V len=
echo ${V[0]}
sum=0 unset V[0] for a in ((a)) done result=echo "scale=3;
len" | bc -l
echo $resultThis question is a bunch of floating point rounding error bullshit. You got it right close enough for all real-world applications if you got all but 1 on the submission.