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
Normal 0 false false false EN-US X-NONE X-NONE MicrosoftInternetExplorer4

In the form of hypermedia documents, Web pages or materials accessed by the Internet can be located anywhere in the world. Regardless of where they originated, most of the Web d

The GuessingGame class contains a skeleton for a program to play a guessing game with the user. The program should randomly generate an integer between 1 and 10 and then ask the us

A non-empty string is called a minimal unique substring of s if and only if it satisfies: (i) α occurs exactly once in s (uniqueness), (ii) all proper prefixes of occur at le

Program for Operate the Rolodex Rolodex is a rotating file, usually used to record business contact information. Cards are inserted in alphabetic order by name. You operate th

Develop (i) a context diagram, and (ii) a use case diagram to model the following functionalities of an online brokerage house. eBroker is a discount online broker. An account h

THERE IS ANY1 COULD HELP ME WITH NETLOGO WORK

A traveler wants to purchase a number of traveler''s checks, each having a set amount for four different currencies: Mexican pesos, Euro dollars, Swiss francs, and US dollars. A t

You must use the keyword ''var'' to create and initialize a variable. The placement of the variable creation in your code is very important. Examples: var first = 21; var secon

1.  Develop a page to indicate distinct attributes of Font tag. 2.  Develop a page to indicate different attributes: bold, italics, underline. 3.  Design a page with backgrou