38. WASS to check whether the word given is a palindrome or not.
Page 1 of 1
38. WASS to check whether the word given is a palindrome or not.
clear
echo "Enter a string"
read str
l=`echo $str | wc -c`
l=`expr $l - 1`
i=1
mid=`expr $l / 2`
while test $l -le $mid
do
a=`expr $str | cut -c $i`
b=`expr $str | cut -c $l`
if test $a != $b
then
echo "It is not a palindrome"
exit
fi
i=`expr $i + 1`
l=`expr $l - 1`
done
echo "It is a palindrome"
-----------> this program has to work fine.. check out people
echo "Enter a string"
read str
l=`echo $str | wc -c`
l=`expr $l - 1`
i=1
mid=`expr $l / 2`
while test $l -le $mid
do
a=`expr $str | cut -c $i`
b=`expr $str | cut -c $l`
if test $a != $b
then
echo "It is not a palindrome"
exit
fi
i=`expr $i + 1`
l=`expr $l - 1`
done
echo "It is a palindrome"
-----------> this program has to work fine.. check out people
sowmya- Posts : 5
Join date : 2010-07-21
Similar topics
» Prog31. WASS to accept a color name from the user and check whether its equal to BLACK , if so print message as accepted else display not accepted.
» 5. WASS to print the following series – 1 3 2 4 3 5 4 ….100
» 3. WASS to find the factorial of a number
» 8. WASS to accept 2 x and y , and find the XY ( x raised to the power y )
» 35. WASS to print your name until the user presses Q or q button
» 5. WASS to print the following series – 1 3 2 4 3 5 4 ….100
» 3. WASS to find the factorial of a number
» 8. WASS to accept 2 x and y , and find the XY ( x raised to the power y )
» 35. WASS to print your name until the user presses Q or q button
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum