Bash shell script to find sum of digits 

echo "enter the number"
read n
rev=0
while [ $n -gt 0 ]
do
tmp=$(( $n % 10 ))
n=$(( $n / 10 ))


rev=$(( $rev + $tmp ))
done
echo $rev

output:-




Post a Comment

If you have any doubts, Please let me know
Thanks!

Previous Post Next Post