English, asked by nikamprerna2002, 3 months ago

write a shell script to accept 5 digit number and perform addition of all digits

Answers

Answered by samiranhalder
0

Answer:

echo "Enter a number" read num sum=0 while [ $num -gt 0 ] do mod=$((num % 10)) #It will split each digits sum=$((sum + mod)) #Add each digit to sum num=$((num / 10)) #divide num by 10. done echo $sum

Similar questions