#@program: To find the sum of all digits by the user
#@author : Binoy Wilson
#@Date   : 4th Jan, 2012

clear;
echo "*********************************";
echo "  PROGRAM : Total Sum Of Number";
echo "*********************************";
echo "Please enter a number of your choice:\c";

#variable to store the no entered by the user
read no;

echo "The number you have selected is     : $no";

#to store the final answer#to store the final answer
finalans=0; 

#using loop to isolate every digit in the number
while [ `expr $no % 10` -ne 0 ]
do
	#The isolated number is stored
	e=`expr $no % 10`;

	#The final sum is optained at the end of the loop in this variable
	finalans=`expr $e + $finalans`;

	# number left after the removal of the isolated number
	no=`expr $no / 10`;
done

echo "                                      *********";
echo " Sum of all its digits are          : $finalans";
echo "                                      *********";

exit 0;