Compute the Average

Sort by

recency

|

361 Discussions

|

  • + 0 comments

    here is my code , my code fails in hidden test case no 2 , can anyone help me , i need my code to as input++ simultaneoulsy count++ , i can't figure it out can anyone help me read n
    sum=0 count=0

    while [ n ] do read num sum=((count + 1)) done avg=sum / avg

  • + 0 comments
    read num
    sum = 0
    for((i=1;i<=$num;i++))
    do
      read x
      sum=$(($sum + $x))
    done
    printf "%.3f" $(echo "$sum/$num" | bc -l)
    
  • + 0 comments

    read n sum=0 for ((i=1;i<=n;i++)) do read temp sum=sum/$n" |bc -l

  • + 0 comments

    !/bin/bash

    read n sum=0

    for (( i=0; i

    Calculate and print average rounded to 3 decimal places

    avg=sum / avg"

  • + 0 comments

    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