Wednesday, 23 November 2016

Finding Sum of Digits

Linux Sum of Digit Program


echo "\t Sum Of Digits "
echo "\t ~~~ ~~ ~~~~~~ "
echo "Enter The Number "
read num
s=0
while test $num -ne 0
do
d=`expr $num % 10`
s=`expr $s + $d`
num=`expr $num / 10`
done
echo " Sum Of Digit " $s

No comments:

Post a Comment