postheadericon Write a shell script to accept the string and checks whether the string is palindrome or not.


clear
echo "Enter String : \c"
read str

len=`echo $str|wc -c`
len=`expr $len - 1`

echo "length of String : "$len

i=1
while [ $i -le $len ]
do
revstr=`echo $str|cut -c$i`$revstr
i=`expr $i + 1`
done

if [ "$revstr" = "$str" ]
then
echo "Your string is palindrome"
else
echo "Your string is not palindrome"
fi

0 comments:

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.