Leap Year Program using Shell Scripting in Linux

  • Post author:
  • Post category:Linux
  • Post comments:1 Comment
  • Reading time:2 mins read

Finding Leap year in C program is very simple one, As same in Shell also we Implement on finding Leap year, I tried this in Ubuntu Linux. Saved with the extension of .sh, and i run this program by using sh <filename>. Lets try out and tell any query if there.

Note : Refer How To Copy The Following Code From This Site:

 

  • Content Stoling is prevented on this site.
  • So Refer this post How to Copy Text from TipsInside to copy the text from this site,

[sourcecode language=’css’]
clear
echo “LEAP OR NON LEAP YEAR ”
echo “Enter the year:”
read a
if [ [$a%4] –eq 0 ]
then
echo “$a is leap year”
else
echo “$a is a non-leap year”
fi
[/sourcecode]

 

OUTPUT:

LEAP OR NON-LEAP YEAR

Enter the year: 1996

1996 is leap year

Enter the year: 2010

2010 is a non-leap year

 

Balaji

, is a computer science graduate. He is interested in sharing the system tweaking ,Web-designing, SEO and tips to use your system fetching you utmost use. Happy tweaking! :D

This Post Has One Comment

  1. tuxy

    It is not sufficient to check year mod 4 alone, this example will fail for some century years such as 1700, 1800 and 1900.

Leave a Reply