Shell Script to find sum of n numbers
Program
#! /bin/bash
sum=0
i=1
echo "Enter the number of terms:"
read n
echo "Enter the numbers:"
while [ $i -le $n ]
do
read a
sum=`expr $a + $sum`
i=`expr $i + 1`
done
echo "Sum is $sum"
Output
$ ./sum-of-n-numbers.sh
Enter the number of terms:
6
Enter the numbers:
14
21
36
10
2
36
Sum is 119