Powered by Blogger.

Write a shell script to find whether a given year(4 digits)is leap year or not.






echo "Enter the year in 4 digits: "
read num
if [ $num -ge 1000 -a $num -le 9999 ]
then
 if [ `expr $num % 4` -eq 0 ]
 then
 echo "The year $num is a Leap year"
 else
 echo "The year $num is not a Leap year"
 fi
else
echo "Invalid year format"
fi

-------------------------------------------------------------------------------------------------
->OUTPUT:
---------

Enter the year in 4 digits:
2000
The year 2000 is a Leap year

*************************************************************************************************
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment