Sunday 15 January 2012

#Program to check whether a entered three digit number is armstrong or not


echo "Enter a three digit number"
read a
b=`expr $a % 10`
c=`expr $a / 10`
d=`expr $c % 10`
c=`expr $c / 10`
e=`expr $b \* $b \* $b + $d \* $d \* $d + $c \* $c \* $c `
if test $e -eq $a
then
echo "Entered number $a is an armstrong"
else
echo "Entered number $a is not an armstrong"
fi

No comments:

Post a Comment