Write a shell script to check entered string is palindrome or not
echo -n "enter string: "
read str
flag=0
cnt=`expr $str : '.*'`
i=1
l=`expr $cnt / 2`
while [ $l -gt $i ]
do
c1=`echo $str|cut -c$i`
c2=`echo $str|cut -c$cnt`
if [ $c1 != $c2 ]
then
flag=1
break
fi
i=`expr $i + 1`
cnt=`expr $cnt - 1`
done
if [ $flag -eq 1 ]
then
echo "Not palindrome"
else
echo "Palindrome"
fi
Shopping In MUMBAI
Are you searching for Discounts, offers, sale in Mumbai ? You are in the right place. MUMBAI, a shopping haven, has no dearth of great discounts and sales. This blog features the best MUMBAI shopping offers, sale, discounts and deals and bargains CURRENTLY GOING on in Mumbai plus a few free things thrown in on top.
Don't wait for it because once they are gone, they are gone. Hurry!..By clicking the "Like" button you will receive a daily update of discounts, sale, offers going on in Mumbai. LIKE IT.... SHARE IT...njoY.
Thursday, February 5, 2009
Program in UNIX to check entered string is palindrome or not
Posted by ars at 5:38 AM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment