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
What is the purpose of scripting?
Is scripting and coding the same thing?
What is awk script?
What is awk in shell scripting?
Explain about return code?
What is the first line of a shell script called?
What is subshell?
How would you compare the strings in a shell script?
What is basename in shell script?
I want to create a directory such that anyone in the group can create a file and access any person's file in it but none should be able to delete a file other than the one created by himself.
How will you pass and access arguments to a script in linux?
Write down the syntax for all the loops in shell scripting.
Write down the syntax of "for " loop
Why are there shells on the beach?
Using set -A write a script to print the output of the ls command in 5 columns with two spaces between each column. Pretend that ls does not have multicolumn output.