Created
August 5, 2020 23:51
-
-
Save jakeywunder/f945d1c7421fe4a2953b390852a59713 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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