Unix Blog

 
 
 
echo \"Enter five digit number \"
read no
total=0
while [ $no -ne 0 ]
do
        temp=\`echo $no % 10 | bc\`
        total=\`echo $total + $temp | bc\`
        no=\`echo $no / 10 | bc\`
done
echo \"Total of digit is : $total\"

 
 
Didn't find what you were looking for? Find more on Program to calculate the sum of its digits