Skip to content

Instantly share code, notes, and snippets.

@jakeywunder
Created August 5, 2020 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakeywunder/f945d1c7421fe4a2953b390852a59713 to your computer and use it in GitHub Desktop.
Save jakeywunder/f945d1c7421fe4a2953b390852a59713 to your computer and use it in GitHub Desktop.
#include <iostream>
int main() {
bool leap_year = false;
int year;
std::cout << "\nInput Year: ";
std::cin >> year;
while (year <= 999 || year >= 10000) {
std::cout << "\nInvalid year, please use a four digit number: ";
std::cin >> year;
}
bool yeardivby4 = !(year % 4);
bool yeardivby100 = !(year % 100);
bool yeardivby400 = !(year % 400);
if (yeardivby4 && (!yeardivby100 || yeardivby100 && yeardivby400) ) {
std::cout << "\nThis year is a leap year!\n";
}
else {
std::cout << "\nThis is not a leap year :(\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment