CPPForSchool.com: Flow of Control Set 1: Assignment 7

7. Any year is input by the user. Write a program to determine whether the year is a leap year or not.

After quickly researching the equation to determine if any particular year is a leap year, I was able to code this program accordingly.  Based on MathsIsFun,

yes Leap Years are any year that can be exactly divided by 4 (such as 2012, 2016, etc)
  not except if it can be exactly divided by 100, then it isn't (such as 2100, 2200, etc)
    yes except if it can be exactly divided by 400, then it is (such as 2000, 2400)

Using the leap year requirements, I was able to create an if statement to test all of those parameters.  See below for source code and output.








Comments

Popular posts from this blog

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 8

CPPForSchool.com: Array - Single Dimension Set 1 Assignment 6

CPPForSchool.com: Variable, Operator & Expression Set 1: Assignment 7