You are on page 1of 1

Ex no : 7.

2 Palindrome or not :
Date :20.3.15

program :

echo "enter the string"


read n
n1=$n
l=`expr length $n`
r=""
i=$l
while [ $i -ne 0
do
x=`expr $n | cut -c $i`
r=$r$x
i=`expr $i - 1`
done
if [ $n == $r ]
then
echo "the given string is palindrome"
else
echo "the given string is not a palindrome"
fi

output :

bash-4.2$ vi revstring.sh
bash-4.2$ sh revstring.sh

enter the string


divyaa
the given string is not a palindrome

bash-4.2$ sh revstring.sh

enter the string


amma
the given string is palindrome

You might also like