Answer to Question #292723 in UNIX/Linux Programming for Lavu

Question #292723

Write a shell script to determine if an input number is a palindrome or not.



1
Expert's answer
2022-02-02T08:19:36-0500

echo "Enter the number"

read n

function pal

{

number=$n

reverse=0

while [ $n -gt 0 ]

do

a=`expr $n % 10 `

n=`expr $n / 10 `

reverse=`expr $reverse \* 10 + $a`

done

echo $reverse

if [ $number -eq $reverse ]

then

   echo "Number is palindrome"

else

   echo "Number is not palindrome"

fi

}

r=`pal $n`

echo "$r"

 



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS