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

Assignment Help:

 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


Related Discussions:- Shell script to check a given number is palindrome or not

Explain the continue statement - computer programming, Explain the Continue...

Explain the Continue statement - Computer Programming? This is alike to break but is encountered less frequently. It merely works within loops where its effect is to force an imm

Write a program to decrypt encrypted messages, You are working for a crypto...

You are working for a cryptography department, where one of your jobs is to decipher intercepted messages that have been encrypted using a book cipher. The messages are sent by dif

Create xml document to save calendar information, Prepare an XML document t...

Prepare an XML document that contains calendar information such as the following text describes: The calendar is owned by a person (e.g. John Smith) and has a few paragraphs tha

Design and implement program, Tamagochi were all the rage in the 90's as a ...

Tamagochi were all the rage in the 90's as a small toy that had limited functionality but modelled a pet. The "owner" could do the following • Feed the pet • Heal the pet

Define parameter passing mechanism - computer programming, Define the Param...

Define the Parameter Passing Mechanism - Computer Programming? The Parameters are syntactically identifiers and they are used within the body of the function and sometimes the

Write simple scripts programs , Write 3 somewhat simple scripts / programs ...

Write 3 somewhat simple scripts / programs in any language, combination of languages, and/or software. Please tell me the task you are trying to accomplish in the scripts. Idea

Creating variables in java script, You must use the keyword ''var'' to crea...

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

Explain cascading style sheets, Question: (a) In JavaScript, the Windo...

Question: (a) In JavaScript, the Window Object is commonly used to request information from a user or to output some results. Give three ways how to create instances of the

Write a program that prints gross and net pay and taxes , Assume that a vid...

Assume that a video store employee works 50 hours. She gets paid $4.50 for the first 40 hours; she gets time-and-a half pay (1.5 times the regular pay rate) for the first five hour

Computer games development, Lazytown Constabulary are concerned that young ...

Lazytown Constabulary are concerned that young people in the town are unaware of the sorts of crime that they might encounter in their daily lives and are concerned that they may b

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd