Write a shell script to determine if an input number is a palindrome or not.
echo "Enter the number"
read nfunction pal{number=$nreverse=0while [ $n -gt 0 ]doa=`expr $n % 10
`n=`expr $n / 10
`reverse=`expr $reverse \* 10 + $a`
done
echo $reverseif [ $number -eq $reverse ]
then
echo "Number is palindrome"else
echo "Number is not palindrome"fi}r=`pal $n`echo
"$r"
Comments
Leave a comment