Dharanyadevi blogspot subsume with E-books, Notes, Lab Manual, Question Banks, Interview Tips, Viva Questions, Basics and Interview Questions for engineering students. For Any Help Contact dharanyadevi@gmail.com

SEARCH

Image

Wednesday, May 2, 2012

Shell Script to Find Whether an Input Number is Palindrome or Not

Palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction (the adjustment of punctuation and spaces between words is generally permitted). Composing literature in palindromes is an example of constrained writing. The word "palindrome" was coined from Greek roots palin ("back") and dromos ("way, direction") by English writer Ben Jonson in the 1600s.

A palindromic number is a number where the digits, with decimal representation usually assumed, are the same read backwards, for example, 58285. They are studied in recreational mathematics where palindromic numbers with special properties are sought. A palindromic prime is a palindromic number that is a prime number.

Program: 
echo
-n "Enter number : "
read n

# store single digit
sd=0

# store number in reverse order
rev=""

# store original number
on=$n

while [ $n -gt 0 ]
do
sd=$(( $n % 10 )) # get Remainder
n=$(( $n / 10 )) # get next digit

# store previous number and current digit in reverse
rev=$( echo ${rev}${sd} )
done

if
[ $on -eq $rev ];
then

echo
"Number is palindrome"
else
echo "Number is not palindrome"
fi




3 comments:

  1. Hi program is clearly explained and can be understand by any student!!! Thank you dharanya!!

    ReplyDelete
  2. Introduce the following basic modifications in order to achieve this
    is to defer purchased from farms links or spamdexing tactics
    such Grey Hat or Black Hat. Simply incorporate major keywords and long tail keywords that
    are especially pertinent to your content. Answer those questions on
    the homepage and make sure to use ALT tags, so keywords included in the content.


    Feel free to visit my page :: website seo rating

    ReplyDelete
  3. Even so does not imply until this the area does not
    have the through stylish automobiles inns.
    Calcium mineral pea gravel. As well as her right behind plan might be supply you with ok, superior,
    and trendy young pieces.

    My web blog - restaurant quality coffee maker

    ReplyDelete

Refer this site 2 ur frndz