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


Please Help Members By Posting Answers For Below Questions

Why is shell scripting important?

565


What is the syntax of "nested if statement" in shell scripting?

624


Determine the output of the following command: name=shubham && echo ‘my name is $name’.

522


What is the equivalent of a file shortcut that we have a window on a linux system?

598


c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again

5198






What is shell environment?

542


What is meant by dos operating system?

570


What are the different communication commands available in the shell?

515


How do I edit a .sh file?

617


What is shell application?

567


Please give me example of " at command , contrab command " how to use

2323


What are script files?

547


Is shell scripting a programming language?

572


Explain about the exit command?

565


What is bash eval?

541