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

Write a script to check whether a given string is palindrome or not.


clear
echo "    STRING PALINDROME OF NOT"
echo "    ========================"
echo "ENTER STRING : "
read str
len=`echo $str | wc -c`
i=1

while [ $i -le $len ]
do
 ch=`echo $str | cut -c $i`
 revstr="$ch$revstr"
 i=`expr $i + 1`
done
if [ "$str" == "$revstr" ];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