Wednesday, 19 June 2013

Write a shell script to determine whether the year entered is a leap year or not?



echo “enter  any year ”
read num
if [ `expr $num % 100` -eq 0 ]
then
if [ `ex pr $num % 400` -eq 0 ]
then
echo "Leap year"
else
echo "Not a leap year"
fi
else
if [ `expr $num % 4` -eq 0 ]
then
echo "Leap year "
else
echo "Not a leap year"
fi
fi





OUTPUT :

enter any year
1999
Not a leap year

enter any year
2000
Leap year

No comments:

Post a Comment