Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

echo "enter no"

read n
sum=0
length="${#n}"
for ((i=0;i<length;i++))
do
d=$((n%10))
sum=$((sum+d))
n=$((n/10))
done
echo "sum of digit for given no is : $sum"

You might also like