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
|
366 Discussions
|
Please Login in order to post a comment
This code will pass all the test cases
read N sum=0
for((i=0; isum/average";
read N sum=0 for ((i=1;i<=N;i++));do read int ((sum+=int)) done ((val=sum/N)) printf "%.3f" $val
What seems to be an issue here?
sum=0 read N
for (( i=1; i<=N; i++)) do read x ((sum += x)) done avg=sum / avg"
*#!/bin/bash read Number for((i=1;i<=((x)) done printf "%.3f" sum/$Number" | bc -l) *