Computer Science, asked by dalton402, 1 year ago

Write a shell script that takes an unspecified number of command line arguments (up to nine) of integers and find their sum.

Answers

Answered by sharmaravikumar78
6

Answer:

sum=0

for i in $@; do sum=$((sum+i)); done

echo $sum

exit 0

Explanation:

This script will take variable arguments ans return the result

Answered by anvimalik867
0

Concept:-

It might resemble a word or a number representation of the quantity's arithmetic value. It could resemble a word or a number that represents the numerical value of the quantity. It could have the appearance of a word or a number that denotes the quantity's numerical value.

Given:-

Given that "write a shell script that takes an unspecified number of command line arguments (up to nine) of integers and find their sum."

Find:-

We need to find that "write a shell script that takes an unspecified number of command line arguments (up to nine) of integers and find their sum."

Solution:-

sum=0

for i in \$@; do sum=\$((sum+i)); done

echo \$sum

exit 0

Hence, this script will take variable arguments ans return the result.

#SPJ3

Similar questions