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 |
How do you read arguments in a shell program - $1, $2 ..?
What is bourne shell scripting?
Explain about login shell?
What is the use of "$#" in shell scripting?
Suppose you execute a command using exec, what will be the status of your current process in the shell?
write a shell script to check the failed jobs?
How can the contents of a file inside jar be read without extracting in a shell script?
What are environment variables?
What is the use of "shift" command in passing parameters?
What is batch file programming?
What is bash used for?
What is the purpose of scripting?