Write a Linux shell script to check whether the entered number is Armstrong number or not using the command line argument, Unix program for Armstrong number
Program
clear
no=$1
n=$1
while[ $n-gt 0]
do
a='expr $n%10'
a3='expr$a\*$a\*$a'
temp='expr$temp+ $a3'
n='expr$temp+$a3'
done
if[$temp-eq$no]
then
echo"It is Armstrong number"
else
echo"It is Armstrong number"
fi
Output:
>sh Armstrong.sh 159
It is Armstrong number
<<< Previous || Current || Next >>>
No comments:
Post a Comment