Answer to Question #13639 in C++ for Chad Dylan Cooper

Question #13639
Write a C++ function named isLeapYear that will take value of a year as a parameter and return whether a year is a leap year or not by returning a boolean value of true or false. A year is a leap year if it is divisible by 4 but not divisible by 100. For example, 1992 and 2008 are divisible by 4, but not by 100. A year that is divisible by 100 is a leap year if it is also divisible by 400. For example, 1600 and 2000 are divisible by 400. However, 1800 is not a leap year because 1800 is not divisible by 400.
1
Expert's answer
2012-08-30T09:45:46-0400
int isLeapYear(int year){
if (year % 4 == 0 && year % 100 != 0) return true;
if (year % 100 == 0 && year % 400 == 0) return true;
return false;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS