Hi Guys, this is another school / college program written in Classic ASP programming language. ASP is one of the oldest programming language, but still you can see some of the big websites are running in this technology.
This post may help you to understand the basics of ASP technology, such as
1. Multiple if conditions using “And” “OR” Operators in Classic ASP
2. Modulus in Classic ASP
Basically to find Leap year, the below conditions has to be satisfied,
1. The entered Year should be able to evenly divided by 4 (year Mod 4 =0)
2. And the Year should not be evenly divided by 100 (year Mod 100 <> 0)
3. Or the year should be evenly divided by 400 (year Mod 400 == 0)
Okay, here is the entire leap year code written in Classic ASP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<html> <head> <title>Classic ASP program to find Leap Year</title> </head> <body> <h3>Classic ASP program to find Leap Year - <a href="http://www.tutorialsmade.com/classic-asp-find-leap-year-not/"> Tutorialsmade.com</a></h3> <!-- form post method --> <form action="" method="post"> <label>Enter Year</label> <input type="text" name="year" size="5" /> <input type="submit" value="Find" name="submit" /> </form> </body> </html> <% 'check if form is submitted If Request.ServerVariables("REQUEST_METHOD") = "POST" Then 'get the entered year from text box dim year year = Request.form("year") 'three conditions to find out the leap year if( (0 = year Mod 4) And (0 <> year Mod 100) Or (0 = year Mod 400) ) then Response.Write(year +" is Leap year") else Response.Write(year +" is not a Leap year") end if end if %> |
Read the comments in the above program to know what is happening in there.
The same program is written in other famous programming languages such as PHP, Java, Python.
Type “Leap year” in the search box and hit enter to get all the programs.
thanks for the helpful code