Write a shell script to check whether a number is Armstrong number or not?



Write a shell script to check whether a number is Armstrong number or not?..

Answer / 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

More Shell Script Interview Questions

What is the difference between a variable and value?

7 Answers   Sun Microsystems,


What is the use of "$?" Sign in shell script?

0 Answers  


I want to upload a file to remote server through ftp daily.Can anyone suggest how to make a shell script for that.I hv credentials for that ftp

1 Answers  


What can scripts do?

0 Answers  


What are the different types of shell scripting?

0 Answers  


How do you create a shortcut in linux?

0 Answers  


Explain about the exit command?

0 Answers  


What command needs to be used to take the backup?

0 Answers  


What is shell company all about?

0 Answers  


Is shell scripting useful?

0 Answers  


What is the difference between scripting and coding?

0 Answers  


what is the difference between sh & bash shell?

1 Answers  


Categories