Reverse of a number Code: clear echo ----------------------------------- echo '\tReverse A Number' echo ----------------------------------- echo Enter the n value read n n1=$n sum=0 while [ $n -gt 0 ] do x=$(expr $n % 10) n=$(expr $n / 10) sum=$(expr $sum \* 10 + $x) done echo Reverse the number $n1 is $sum Output: ----------------------------------- Reverse A Number ----------------------------------- Enter the n value 123 Reverse the number 123 is 321
Leave a Comment