[upon request] Shell program to find palindrome of a number

echo "enter the number"
read num
t=$num
while [ $num -gt 0 ]
do
rem=$((num%10))
rev=$((((rev * 10 )) + $rem))
num=$((num/10))
done
if [ $rev -eq $t ]
 then
echo "palindrome"
else
echo "not palindrome"
fi

No comments:

Post a Comment