Skip to content

Instantly share code, notes, and snippets.

@CodeMaster7000
Created February 15, 2022 12:06
Show Gist options
  • Save CodeMaster7000/5ba21b7c161f1e0a733b4e722c88e873 to your computer and use it in GitHub Desktop.
Save CodeMaster7000/5ba21b7c161f1e0a733b4e722c88e873 to your computer and use it in GitHub Desktop.
A program coded in C++ which checks whether the input year is a leap year or not.
#include <iostream>
using namespace std;
int main() {
int year;
cout << "Enter a year: ";
cin >> year;
if (year % 400 == 0) {
cout << year << " is a leap year.";
}
else if (year % 100 == 0) {
cout << year << " is not a leap year.";
}
else if (year % 4 == 0) {
cout << year << " is a leap year.";
}
else {
cout << year << " is not a leap year.";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment