normal 0 false false false en-us x-none


  W.A.S.S to check whether a given number is Armstrong number or not.

 

Program

 

# W.A.S.S to check that whether a given number is prime or not.

 

echo "Enter the Number:"

read num

tnum=$num

temp=0

sum=0

 

while test $num -gt 0                                   #while loop

do

   temp=`expr $num % 10`          #extract the digit by digit

   temp=`echo $temp^3 | bc`       #make the cube of digit using bc - An arbitrary

        #precision calculator

   sum=`expr $sum +  $temp`     #calculate sum of cube of all the digit

   num=`expr $num / 10`

done                                      

 

if test $sum -eq $tnum           #if the sum of cube of all the digit of given no is same as no

then

echo "Entered no $tnum is Armstrong number"

else

echo "Entered no $tnum is Not an armstrong number"

fi

 

Output

 

Enter the Number:

151

Entered no 151 is Not an armstrong number

Enter the Number:

153

Entered no 153 is Armstrong number

Request for Solution File

Ask an Expert for Answer!!
Application Programming: normal 0 false false false en-us x-none
Reference No:- TGS0161475

Expected delivery within 24 Hours