Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int first, last, count = 0;
- cout << "From : "; cin >> first;
- cout << "To : "; cin >> last;
- for (int i = first; i <= last; i++) {
- if (i % 400 == 0) {
- cout << i << " is a Leap Year." << endl;
- count++;
- }
- else if (i % 4 == 0 && i % 100 != 0) {
- cout << i << " is a Leap Year." << endl;
- count++;
- }
- else cout << i << " is not a Leap Year." << endl;
- }
- cout << "\nTotal leap years in this range: " << count << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement