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.

## 4 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.

there are six Armstrong numbers in the range of 0 and 999.

Armstrong number 1: 0

Armstrong number 2: 1

Armstrong number 3: 153

Armstrong number 4: 370

Armstrong number 5: 371

Armstrong number 6: 407

## Post a Comment