Custom Search

Friday, 20 April 2012

Write a Linux shell script to check whether the string is palindrome, Unix program to check whether the string is palindrome


Write a Linux shell script to check whether the string is palindrome, Unix program to check whether the string is palindrome


Program
clear 
echo"Enter any string:"
read a


b=$a
d='expr$a| wc-c'
c='expr$d-1


While [$c-gt 0]
do
  n='expr $a|cut-c$c'
  r=$r$n
  c='expr$c-1
done


echo$r


if[$b==$r]
then
  echo"String is palindrome"
else 
  echo"Not palindrome string"
fi


Output:
Enter any string:
madam
madam
String is palindrome.
<<< Previous  ||  Current  ||  Next >>>  

No comments:

Post a Comment

Laptops