postheadericon Write a script to check whether a given number is palindrome or not


File Name : ex21.sh


clear
echo "Enter No : \c"
read no

m=$no
rev=0

while [ $no -gt 0 ]
do
            r=`expr $no % 10`
            rev=`expr $rev \* 10 + $r`
            no=`expr $no / 10`
done

if [ $m = $rev ]
then
            echo " [ $m] is Palindrome"
else
            echo " [ $m ] is not Palindrome"
fi


4 comments:

Follow by Email

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.