echo enter a year
read n
if test `expr $n % 4` -eq 0
then
echo leap year
else
echo not a leap year
fi
~
~
OUTPUT
[staff@linuxserver staff]$ sh
leap
enter a year
2008
leap year
[staff@linuxserver staff]$ sh
leap
enter a year
2009
not a leap year
echo "enter the number"
read n
echo "The result is"
c=0
a=0
b=1
echo "$a"
echo "$b"
n=`expr $n - 2`
while test $n -ne 0
do
c=`expr $a + $b`
echo "$c"
a=$b
b=$c
n=`expr $n - 1`
done
~
OUTPUT:
[eceb33@linuxserver eceb33]$ sh fiboo
enter the number
8
The result is
0
1
1
2
3
5
8
13
No comments:
Post a Comment