Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is the significance of the shebang line in shell scripting?

1039


How do scripts work?

990


Explain about non-login shell files?

1132


Is shell a part of kernel?

993


How to print all the arguments provided to the script?

905


Explain about the slow execution speed of shells?

1159


How to check if the previous command was run successfully?

984


What is bash shell command?

956


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

1092


What is the best scripting language?

963


What is meant by dos operating system?

988


What is the purpose of scripting?

1002


What are "c" and "b" permission fields of a file?

966


What is the crontab?

1006


Explain about gui scripting?

1036