Featured Post

Thursday, March 24, 2016

shell program to check whether the given number is armstrong or not

/* arm.sh */



echo "enter any number"
read num
n=$num
sum=0
while [ $n -gt 0 ]
do
      r=`expr $n % 10`
      sum=`expr sum + (r*r*r)`
      n=`expr $n / 10`
done
if [ $sum -eq $num ]
then
echo "given number is armstrong number"
else
echo "given number is not armstrong"
fi


/home/anil/~$ sh arm.sh
enter any number
153
given number is armstrongnumber



Unix operating system Linux operating system shell programming bourn shell kourne shell c shell difference between unix and linux operating system , history of UNIX, red hat operating system. UNIX OS architecture , kernel utility programs , file handling process handling inter process communication pipes shared memory message queues socket programming TCP/IP , UDP programming , One to One chat Application , Basic shell program to add two numbers , echo function , while loops clear gt lt le ge ne eq if fi while do done case array in unix strings , cut copy paste cat dir pwd getcwd chdir command read write stat lseek fstat flock mechanism.even or add program vi editor command ni vi editor command mode esc mode insert mode aa dd x :q :wq :w

No comments:

Post a Comment