Showing posts with label Operating System Programs. Show all posts
Showing posts with label Operating System Programs. Show all posts

WRITE A SHELL SCRIPT TO CHECK A NUMBER IS ARMSTRONG OR NOT

echo “Enter the number:”
read n
c=0
k=$n
p=$n
while test $k –ne 0
do
c=`expr $c + 1`
k=`expr $k \/ 10`
done
s=0
while test $p –ne 0
do
r=`expr $p % 10`
m=1
i=1
while test $i –le $c
do
m=`expr $m \* $r`
i=`expr $i + 1`
done
s=`expr $s + $m`
p=`expr $p \/ 10`
done
if test $s –eq $n
then
echo “$n is Armstrong”
else
echo “$n is not Armstrong”
fi



WRITE A SHELL SCRIPT TO PERFORM BUBBLE SORT


echo “Enter the number of element:”
read n
i=1
while test $i -le $n
do
var=a$i
echo “Enter the number:”
read $var
i=`expr $i + 1`
done
i=1
while test $i -le `expr $n - 1`
do
while test $j -le `expr $n -$i`
do
num1=a$j
num2=a`expr $j + 1`
if eval test \$$num1 –gt \$$num2
then
eval t=\$$num1
eval $num1=\$$num2
eval $num2=$t
fi
j=`expr $j + 1`
done
i=expr $i + 1`
done
echo “The sorted list is:”
i=1
while test $i -ne $n
do
num=a$i
eval echo \$$num
i=`expr $i + 1`

done


Subscribe

Milan Panda
Admin
About Me | Contact
Copyright 2023-2024 © Programming1011 . 🎀 Developed and Design By- Milan Panda. Happy Holi All Of You 🎀