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

How do you read arguments in a shell program - $1, $2 ..?

4 Answers  


What is bourne shell scripting?

0 Answers  


Explain about login shell?

0 Answers  


What is the use of "$#" in shell scripting?

0 Answers  


Suppose you execute a command using exec, what will be the status of your current process in the shell?

0 Answers  






write a shell script to check the failed jobs?

0 Answers   Wells Fargo,


How can the contents of a file inside jar be read without extracting in a shell script?

0 Answers  


What are environment variables?

2 Answers  


What is the use of "shift" command in passing parameters?

1 Answers  


What is batch file programming?

0 Answers  


What is bash used for?

0 Answers  


What is the purpose of scripting?

0 Answers  


Categories