Headlines
Loading...
Program in UNIX to determine whether the year is a leap year or not

Program in UNIX to determine whether the year is a leap year or not

Write a shell script, which receives any year from the keyboard and determines whether the year is a leap year or not. If no argument is supplied the current year should be assumed.

echo "Enter Year"
read yr
if [ -s $yr ]
then
   yr=`date +%Y`
fi

if [ `expr $yr % 4` -eq 0  -a \( `expr $yr % 400` -eq 0 -o  `expr $yr % 100` -ne 0 \) ]
then
   echo "Entered year is leap year"
else
   echo "Entered year is not a leap year"
fi
*** PLEASE checkout the Best deals from for top sites like Amazon, Flipkart etc ***