WRITE A SHELL SCRIPT TO CHECK A NUMBER IS ARMSTRONG OR NOT

No comments
echo “Enter the number:”
read n
c=0
k=$n
p=$n
while test $k –ne 0
do
c=`expr $c + 1`
k=`expr $k \/ 10`
done
s=0
while test $p –ne 0
do
r=`expr $p % 10`
m=1
i=1
while test $i –le $c
do
m=`expr $m \* $r`
i=`expr $i + 1`
done
s=`expr $s + $m`
p=`expr $p \/ 10`
done
if test $s –eq $n
then
echo “$n is Armstrong”
else
echo “$n is not Armstrong”
fi



No comments :

Post a Comment

Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀