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
|
345 Discussions
|
Please Login in order to post a comment
if [ "N" -gt 500 ]; then echo "N must be between 1 and 500" exit 1 fi
sum=0
for (( i=0; ix" -gt 10000 ]; then echo "Each integer must be between -10000 and 10000" exit 1 fi sum=$((sum + x)) done
Hello, In all the solutions describe here, It allways start with read n or read N
what i dont understand is why the variable n or N register the number of value entered (so we can devide by N at the end) and not the value itself ?
hope my english is correct and my question understandable ... thanks
read n sum=0 for((i=0;i
result=sum/$n" | bc) one test case is not passed y
one printf "%0.3f" $result
read n sum=0 for((i=0;i
result=sum/$n" | bc) one test case is not passed y
one printf "%0.3f" $result