Write a shell script to check whether a number is Armstrong number or not?
Answer Posted / 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 |
Post New Answer View All Answers
Why is shell scripting important?
What is the syntax of "nested if statement" in shell scripting?
Determine the output of the following command: name=shubham && echo ‘my name is $name’.
What is the equivalent of a file shortcut that we have a window on a linux system?
c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and exit on pressing Ctrl-C again
What is shell environment?
What is meant by dos operating system?
What are the different communication commands available in the shell?
How do I edit a .sh file?
What is shell application?
Please give me example of " at command , contrab command " how to use
What are script files?
Is shell scripting a programming language?
Explain about the exit command?
What is bash eval?