Monday 16 January 2012

#program to check whether a entered year is leap year or not


echo "Enter a year "
read year
if test `expr $year % 100` -eq 0
then
 if test `expr $year % 400` -eq 0
 then
 echo "Entered year $year is a leap year "
 else
 echo "Entered year $year is not a leap year "
 fi
elif test `expr $year % 4` -eq 0
then
 echo "Entered year $year is a leap year "
 else
 echo "Entered year $year is not a leap year "
fi

No comments:

Post a Comment