Thursday, May 1, 2008

Write a shell script which receives any year as an argument while executing the script. If the argument is not supplied then the year should be receiv

# SS9

# Script to determine whether a given year is leap or not

# Usage: SS9 [year]

if [$# -eq 0 ]

then

echo Enter year

read year

else

year=$1

fi

if [‘expr $year %100‘ -eq 0 ]

then

if [ ‘expr $year %400‘ -eq 0 ]

then

echo $year is a leap year

else

echo $year is not a leap year

fi

else

if [‘expr $year %4‘ -eq 0 ]

then

echo $year is a leap year

else

echo $year is not a leap year

fi

fi

No comments: