Write a shell script to check whether a number is Armstrong number or not?
Answer / kirtiranjan sahoo
read -p "Enter any number : " no
rev=0
temp=$no
while [ $no -ne 0 ]
do
dig=$(( $no%10 ))
rev=$(( $rev+$dig*$dig*$dig ))
no=$(( $no/10 ))
done
if [ $rev -eq $temp ]
then
echo "Armstrong"
else
echo "Not Armstrong"
fi
| Is This Answer Correct ? | 26 Yes | 23 No |
What is sh in shell script?
What does $$ mean in shell script?
how do you write sql queries using shell script for eg:- we have databae table like EMPNO,ENAME,SAL,DEPTNO columns in EMP table how you display EMPNO,SAL FIELDS from emp in SHELL SCRIPT please explain with an example
What is MUTEX?
shell script for reverse the string
What is difference between bash and shell?
What is shell application?
What is k shell?
How to take input values from the user?
how to print the matrix form of 2-d, 3-d arrays in unix c shell scripts ?
What is bash used for?
In which variable prompt value is stored?