echo "Enter a number: "

read c

x=$c

sum=0

r=0

n=0

while [ $x -gt 0 ]

do

r=`expr $x % 10`

n=`expr $r \* $r \* $r`

sum=`expr $sum + $n`

x=`expr $x / 10`

done

if [ $sum -eq $c ]

then

echo "It is an Armstrong Number."

else

echo "It is not an Armstrong Number."

fi

--------------------------------------------------------------------------------------------------------------

OUTPUT

Enter a number:

153

It is an Armstrong Number.

## 3 comments:

thank you so much ...!! :)

it's helpful

Thnx...realy its very help ful

In this program if i give a four digit number or a number less than 3 digits, for eg. If i give input as 2 then it will give output as not armstrong, which is wrong. This program will only work for 3 digit numbers. So junior get your concept cleared first.

## Post a Comment