Shell script to check a given number is palindrome or not, Programming Languages

 W.A.S.S to check whether a given number is palindrome or not.

 

Program

 

   # W.A.S.S to check whether a given number is palindrome or not.

 

echo "Enter any no.:"

read num

temp=$num

rem=0

len=0

result=0

 

while test $temp -gt 0            # loop to find the revese of the given number

do

rem=`expr $temp % 10`

result=`expr $result \* 10 + $rem`

temp=`expr $temp / 10`

done

echo "$result "

 

if test $result = $num             #if reverse of no is same as given no  

then

echo "Entered no is palimdrom"

else

echo "Entered is not a palimdrom"

fi

 

Output

 

Enter any no.:

1221

1221

Entered no is palimdrome

 

Enter any no.:

1234

4321

Entered is not a palimdrome

Posted Date: 9/26/2012 4:47:02 AM | Location : United States







Related Discussions:- Shell script to check a given number is palindrome or not, Assignment Help, Ask Question on Shell script to check a given number is palindrome or not, Get Answer, Expert's Help, Shell script to check a given number is palindrome or not Discussions

Write discussion on Shell script to check a given number is palindrome or not
Your posts are moderated
Related Questions
Attributes to Elements Create an XSLT stylesheet that converts all attributes found in a given XML document to elements.Use the sample instance from question 2 to test the tra

Each of the following two procedures defines a method for adding two positive integers in  terms of the procedures inc, which increments its argument by 1, and dec, which decrement

Villa La Fourche Ltd is a small family business situated in the East Coast of Mauritius, more precisely Trou d'eau Douce.   The compound comprises of 6 independent villas, each of


Write out the Syntax of Nested if Statements? The universal form is                         If(expression 1)                         {

1. Write a bash shell script which searches through your folders for files with the extension *.tex, and then interactively deletes the corresponding *.aux, *.dvi and *.log files (

We want to create a structure that will represent a deck of cards  (not necessarily full). Each card has a character (between  '2'  to  '9' and  'T',  'J',  'Q',  'K',  'A') and a


Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

I need an application that will gather data from one SQL Database and update another. Data is contained in dbo.CallList with following fields: Customer_ID, AlreadyPickedUp, Phone_N