HTMLify
check-leap-year.cpp
Views: 606 | Author: demo
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | #include <iostream> using namespace std; int main() { int year; cout << "Enter a year: "; cin >> year; // leap year if perfectly divisible by 400 if (year % 400 == 0) { cout << year << " is a leap year."; } // not a leap year if divisible by 100 // but not divisible by 400 else if (year % 100 == 0) { cout << year << " is not a leap year."; } // leap year if not divisible by 100 // but divisible by 4 else if (year % 4 == 0) { cout << year << " is a leap year."; } // all other years are not leap years else { cout << year << " is not a leap year."; } return 0; } |