Friday, 12 December 2014

Shell Script for Palindrome number

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

Solution:
echo Enter the number
read num
d=`expr $num`
c=0
while [ $d -gt 0 ]
do
b=`expr $d % 10`
d=`expr $d / 10`
c=`expr $c \* 10 + $b`
done
if test $num -eq $c
then
echo The Given number is Palindrome
else
echo The number is not a Palindrome
fi

Execution:


No comments:

Post a Comment