write a shell script to identify the given string is
palindrome or not?
Answer Posted / siva
echo "PALINDROME NUMBER"
echo "ENTER THE NUMBER :"
read n
n1=$n
rev=0
while [ $n1 -ne 0 ]
do
rem=`expr $n1 % 10`
n1=`expr $n1 / 10`
rev=`expr $rem + $rev \* 10`
done
if [ $n -eq $rev ]
then
echo $n is a Palindrome Number
else
echo $n is not a Palindrome Number
fi
PALINDROME NUMBER
ENTER THE NUMBER :
121
121 is a Palindrome Number
$sh palno.sh
PALINDROME NUMBER
ENTER THE NUMBER :
123
123 is not a Palindrome Number
| Is This Answer Correct ? | 24 Yes | 7 No |
Post New Answer View All Answers
How do I run a .sh file on mac?
How can any user find out all information about a specific user like his default shell, real-life name, default directory, when and how long he has been using the system?
What is the lifespan of a variable inside a shell script?
What is the purpose of scripting?
What is shell geeksforgeeks?
madhar chod unix ke 10 commands dhang se likh nahi sakta hai
How do I open the shell prompt?
What does $@ mean bash?
Is shell scripting useful?
Write down the syntax of "for " loop
What is in a script?
How do I debug a shell script?
How to get the last line from a file using just the terminal?
Explain about echo command?
How will you emulate wc –l using awk?