Code In Tech - The Ultimate World of Computer Technology

Saturday, 12 May 2012

Shell script to reverse the given no.

SOURCE CODE:

echo  “Enter the no.:”
read n
l =`expr length $n `
a=1
d=$n
while [ $a –le $l ]
do
     m=`expr $d % 10`
     d=`expr $d / 10`
     s=$s$m
     a=`expr $a + 1`
done
echo $s

OUTPUT

Enter the no.:
123
321  

No comments :

Post a Comment