Subscribe to Get Free Material Updates!
Visit my new blog WebData Scraping - Web Scraping Service provider company in India.

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 is "$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 "string is palindrome"
else
 echo "string is not palindrome"
fi


Output:

0 comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes