Write A Shell Script To Check For Palindrome or Not in Redhat Linux

Check the number whether given number is palindrome or not

Source Code Programming
#Shell Script to display palindrome number
tput clear
echo "Enter the no:"
read n
sd=0
rev=" "
on=$n
while [ $n -gt 0 ]
do
sd=$(( $n % 10 ))
n=$(( $n / 10 ))
rev=$( echo ${rev}${sd} )
done
=$(( $n / 10 ))
rev=$( echo ${rev}${sd} )
else
echo " Not palindrome"
fi


Output Palindrome or Not
Enter the no:
1234
Not palindrome

Enter the no:
121
Number is palindrome
CONCLUSION: The following shell script checks the given number is palindrome or not.

Post a Comment

0 Comments