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
You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following i

My kinect hand cursor only works for main menu but when it goes to another page it wouldn''t work.. especially when there is for camera feed

Introduction Each module of the course includes a programming project. However, for Modules 5 and 6 we will do a single project to cover both. The purpose of the programming p

Expertsmind brings you unique solution in java assignments Multithreaded Programming Java provides built-in support for multithreaded selection. A multithreaded applicatio

Example problem Imagine that  you  require  to create  a robot  that  will  roll up  close to a light  lamp  and  stop  a fixed distance from it.  The first question is, how w

Characteristics of procedure-oriented programming: Emphasis is on doing things (algorithms). Large programs are divided into smaller programs known as functions.

The languages used in the module are of a type known as high-level languages. There is another set of languages known as low-level languages. (a) Differentiate between high-leve

Use an insertion sort to sort an array (sequence) of long word integers. The size of the list will appear just before the list itself. Use the same labels as in this example: LE

The ?rst task in the project is to develop a sane system to store change logs and versions of ?les. The simplest approach is to create a "dot" directory in the location of the ?le

NOTE: You will only submit the University.java and EmptyFileException.java files (inside P3.zip/tar) NOTE on null objects:. From Project 1: Since the array of students in the Cou