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


Comments

Popular posts from this blog

Write a Program to Add two 3x3 Matrix using C

C program for Unit Conversion

Write a Program to Add two 5x5 Matrix using C