echo "ENTER A NUMBER-"
read n
rev=0
t=$n
while test $n -ne 0
do
r=`expr $n % 10`
rev=`expr $rev \* 10`
rev=`expr $rev + $r`
n=`expr $n / 10`
done
echo "THE REVERSE IS-$rev"
if test $rev -eq $t
then
echo "THE NUMBER IS PALINDROME"
else
echo "THE NUMBER IS NOT PALINDROME"
fi
OUTPUT:
ENTER A NUMBER-
121
THE REVERSE IS-121
THE NUMBER IS PALINDROME
121
THE REVERSE IS-121
THE NUMBER IS PALINDROME
No comments:
Post a Comment