Write a shell script to check whether a number is Armstrong number or not?
Answer Posted / kirtiranjan sahoo
read -p "Enter any number : " no
rev=0
temp=$no
while [ $no -ne 0 ]
do
dig=$(( $no%10 ))
rev=$(( $rev+$dig*$dig*$dig ))
no=$(( $no/10 ))
done
if [ $rev -eq $temp ]
then
echo "Armstrong"
else
echo "Not Armstrong"
fi
| Is This Answer Correct ? | 26 Yes | 23 No |
Post New Answer View All Answers
What is the use of "$?" Sign in shell script?
What is $1 in shell scripting?
I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.
What is shell chemistry?
Explain about the slow execution speed of shells?
What is meant by $1 in shell script?
How to set an array in linux?
How to print pid of the current shell?
how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
What is the syntax of while loop in shell scripting?
Explain about the exit command?
write a shell script to generate a alert ? like when ur birthday came then generate a alert ur birthday is today like that ?
What are the types of script?
What does $$ mean in shell script?
how to print the 2-d, 3-d arrays in unix shell script programs please answer thi questio to my mail venusaikumar@gmail.com