Sum of Digits using [Shell Program]



echo "Enter a
number: \c"


read num


sum=0


while [ $num -ne 0 ]


do


x=`expr $num %
10`


sum=`expr $x +
$sum`


no=`expr $num /
10`


done


echo "The sum of
digits are :"
$sum


0 Comments