Advertisement
ItzEdInYourBed

leap_year.cpp

May 16th, 2020
1,062
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.   if (yearInput > 1000 && yearInput < 9999){
  8.     if (yearInput % 4 == 0 && yearInput % 100 != 0 || yearInput % 400 == 0){
  9.       std::cout << "The year " << yearInput << " is a leap year.\n";
  10.     }else{
  11.       std::cout << "The year " << yearInput << " is not a leap year.\n";
  12.     }
  13.   }else{
  14.       std::cout << yearInput << " is an invalid year\n";
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement