Quantcast
Channel: Small Basic
Viewing all articles
Browse latest Browse all 669

Featured Small Basic Article - Leap Year Checker

$
0
0

Today I'm featuring this Wiki article:

 

Here is the overview from that article:

For example, let’s say you want to create a program that checks whether a given year’s a leap year or not. It’s a leap year if the year’s evenly divisible by 4. But if it’s evenly divisible by 100, then it also needs to be evenly divisible by 400. The Figure shows you a flowchart of what you’d need to test for.

   

Figure: A flowchart for checking if a given year’s a leap year

Here are three examples of these rules:

  1. Year 2020 is divisible by 4. Since it isn’t evenly divisible by 100, it’s a leap year!
  2. Year 2100 is divisible by 4. Because it’s evenly divisible by 100, you need to check its divisibility by 400. Since it isn’t evenly divisible by 400, it’s not a leap year.
  3. Year 2400 is divisible by 4. Because it’s evenly divisible by 100, you’ll need to check its divisibility by 400. Since it’s evenly divisible by 400, it’s a leap year!

 

For the latest version, you can head to the Wiki article. You can also get the code, output examples, and an explanation of what the code does:

 

Have a Small and Basic New Year!

   - Ninja Ed

 

 


Viewing all articles
Browse latest Browse all 669

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>