Write a Shell Script to find the Reverse and Sum of a the entered numbers
Solution:
Solution:
echo Enter any number
read n
rev=0
sd=0
sum=0
while [ $n -gt 0 ]
do
sd=`expr $n % 10`
rev=`expr $rev \* 10 + $sd`
sum=`expr $sum + $sd`
n=`expr $n / 10`
done
echo "Reverse number is $rev"
echo " sum of digits are $sum"
Execution:
No comments:
Post a Comment