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,
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,
Leap Years are any year that can be exactly divided by 4 (such as 2012, 2016, etc) | |||
except if it can be exactly divided by 100, then it isn't (such as 2100, 2200, etc) | |||
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
Post a Comment