Write a shell script to check whether a number is Armstrong number or not?



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

Post New Answer

More Shell Script Interview Questions

How to write an Auto scripting for deleting old files using shell script and made a cron job to run on daily basis

1 Answers  


What are the different commands available to check the disk usage?

0 Answers  


Write a shell script to check whether a number is Armstrong number or not?

1 Answers   Flipkart,


How to print the first array element?

0 Answers  


How to get the last line from a file using just the terminal?

0 Answers  






How will you connect to a database server from linux?

0 Answers  


Is powershell a bash?

0 Answers  


What is the significance of $#?

0 Answers  


what are bootlevel in linux?which level is booting by default.

5 Answers   Symphony,


What is the command for " how many shell is running in your system or how many shell supported by your system " ?.

3 Answers  


Hi, all Scripting professional. Q. I have written script1.sh and calling script2.sh in script1.sh file using bash shell as interpreter and my log in shell also bash shell.My code like Script1 #!/bin/bash echo "My script2 call" . script2.sh Here script2.sh file run successfully but when I have changed my interpreter bash to ksh like #!/bin/ksh Error are comming script2.sh command not found. Guid me how to call other script in our main script.

2 Answers  


State the advantages of shell scripting?

0 Answers  


Categories