Shell Programming Exp - No:2.a Menu Operation Program
Shell Programming Exp - No:2.a Menu Operation Program
Exp.No:2.a
Menu Operation
Program:
echo Menu
echo 1.List of users
echo 2.Date
echo 3.Current working directory
echo 4.Calendar of the month
echo Enter your choice
read choice
case $choice in
1)who;;
2)date;;
3)pwd;;
4)cal 8 2008;;
esac
Exp.No:2.b
Program:
echo Enter the number
read n
fact=1
i=1
while [ $i -le $n ]
do
fact=`expr $fact \* $i`
i=`expr $i + 1`
done
echo Factorial of $n is $fact
Factorial
Exp.No:2.c
Program:
Fibonacci Series
Exp.No:2.d
Program:
echo Enter the number
read n
t=$n
s=0
while [ $n -gt 0 ]
do
r=`expr $n % 10`
s=`expr $s + \( $r \* $r \* $r \)`
n=`expr $n / 10`
done
if [ $t -eq $s ]
then
echo Number is Armstrong
else
echo Number is not Armstrong
fi
Armstrong Number
Exp.No:2.e
Program:
Prime Number