**AIM:**

To write a shell program to check whether the given number is Armstrong or not.

**ALGORITHM:**

· Enter the given number.

· Separate the digit using the formula q=`expr $n % 10` and r=`expr $n % 10`.

· Calculate sum of cube of digits by the formula a=`expr $a + $r /* $r /* $r`.

· Compute the result with the given number.

· if found equal then display it as Armstrong number else display not Armstrong number.

**PROGRAM SOURCE CODE**

echo ”enter the number”

read n

q=$n

a=0

while [ $q – gt 0 ]

do

r= `expr $q % 10 `

q= `expr $q / 10 `

a=`expr $a + $r /* $r /*$r `

done

if [ $a=$n ]

then

echo “the number $n is armstrong number”

else

echo “the number $n is not armstrong number”

fi

**CONCLUSION:**

Thus the shell program to check whether a number is armstrong or not is written and executed successfully.

## No comments:

Write comments