Advertisement
ItzEdInYourBed

leap_year.cpp

May 16th, 2020
981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. int main() {
  4.   int yearInput;
  5.   std::cout << "Please input a year:\n";
  6.   std::cin >> yearInput;
  7.  
  8.   if (yearInput > 1000 || yearInput < 9999){
  9.     if (yearInput % 4 == 0 && yearInput % 100 != 0 || yearInput % 400 == 0){
  10.       std::cout << "The year " << yearInput << " is a leap year.\n";
  11.     }else {
  12.       std::cout << "The year " << yearInput << " is not a leap year.\n";
  13.     }
  14.   }else {
  15.       std::cout << yearInput << " is an invalid year\n";
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement