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 significance of the shebang line in shell scripting?
How do scripts work?
Explain about non-login shell files?
Is shell a part of kernel?
How to print all the arguments provided to the script?
Explain about the slow execution speed of shells?
How to check if the previous command was run successfully?
What is bash shell command?
What is the use of "$?" Sign in shell script?
What is the best scripting language?
What is meant by dos operating system?
What is the purpose of scripting?
What are "c" and "b" permission fields of a file?
What is the crontab?
Explain about gui scripting?