Hi All,
need help with reading the array and sum of the array elements.
given an array of integers of size N . You need to print the sum of the elements in the array, keeping in mind that some of those integers may be quite large.
Input Format
The first line of the input consists of an integer N . The next line contains space-separated integers contained in the array.
Output Format
Print a single value equal to the sum of the elements in the array.
1<=N<=10
0<=A<=10000000000
5
1000000001 1000000002 1000000003 1000000004 1000000005
Output
5000000015
what I have done so far:
code:
#input array size
read N
while [ $N -ge 1 -a $N -le 10 ]
do
echo $N
break
done
for i in `seq 0 N-1`;
do
read -a array
if[ "${array}" -ge 0 -a "${array}" -le 10000000000 ]; then
echo "${array}"
fi
done
#sum=expr `sum + ${ array }`
Could you please let me know where I went wrong?