Answer to Question #303590 in UNIX/Linux Programming for Sunitha

Question #303590

Write a shell script program to find average of first N even numbers?


1
Expert's answer
2022-02-28T01:07:22-0500
#shell script to find average of n numbers
  
echo "Enter Size(N)"
read N

i=1
sum=0

echo "Enter Numbers"
while [ $i -le $N ]
do
  read num               #get number
  sum=$((sum + num))     #sum+=num
  i=$((i + 1))
done

avg=$(echo $sum / $N | bc -l)

echo $avg

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS