Pure Programmer
Blue Matrix


Cluster Map

Project: Leap Year Determination

Write a program to determine if a given calendar year is a [[leap year]]. Leap years are generally those that are evenly divided by 4. There is an exception, however, for years that are evenly divisible by 100 but not by 400. Test with the values 2016 (a leap year), 2015 (not a leap year), 2000 (a leap year), 1900 (not a leap year). You should write a function isLeapYear() that takes a year argument and returns true or false.

Output
$ rustc LeapYear2.rs warning: function `isLeapYear` should have a snake case name --> LeapYear2.rs:10:4 | 10 | fn isLeapYear(Y:isize) -> bool { | ^^^^^^^^^^ help: convert the identifier to snake case: `is_leap_year` | = note: `#[warn(non_snake_case)]` on by default warning: variable `Y` should have a snake case name --> LeapYear2.rs:10:15 | 10 | fn isLeapYear(Y:isize) -> bool { | ^ help: convert the identifier to snake case (notice the capitalization): `y` warning: 2 warnings emitted $ ./LeapYear2 1900 is NOT a leap year. 2000 is a leap year. 2012 is a leap year. 2019 is NOT a leap year.

Solution