Write a shell script program to find average of first N even numbers?
#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
Comments
Leave a comment