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
This assignment begins software tools and techniques for structuring complex programs. Use it to become familiar with these facilities, and ensure you use the speci?ed concepts in

We will be assuming here that our roots are of the form, in this case, r 1,2 = l + mi If we take the first root we'll find the following solution. x l + m i It i

i attached the assignment document only i need your help with following three parts: accessible areas, accessible cul-de-sacs that are all connected, entry-exit path with no in

In this exercise you will develop a small 'Pop Game' in which the user will "pop" shapes that are drawn on the screen. The game will be time based, showing a shot clock at the top

list of 10 operating systems with their hardware specification and also list any 5 software associated with each operating system

AMCC PowerPC 440 EPx Sequoia Evaluation Kit, Embedded Linux Development Kit (ELDK), and Xenomai A. Description of the Project The project's objective is to design a set of

Define a Prolog predicate flatten(List, FlattenedList)  that asserts List  is any nested list of atoms and  FlattenedList  is the same list with the nesting removed. The atom [] sh

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

The creation of the menu will involve writing procedural code, using decision logic, writing a loop, and using the case statement.  Although it is not required for grading, it is r

Introduction This assignment builds on your application, produced in Assignment 1, which holds a list of cabins, which can be either read in from a text file or just hard coded