SHARE
TWEET

Untitled

alex_doan_ Dec 10th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2.  
  3. using namespace std;
  4.  
  5. bool checkLeapYear(int year){
  6.    if(year<0){
  7.       return false;
  8.    }
  9.    else if(year % 400 == 0){
  10.       return true;
  11.    }
  12.    else if(year % 100 == 0){
  13.       return false;
  14.    }
  15.    else if(year % 4 == 0){
  16.       return true;
  17.    }
  18.    return false;
  19. }
  20.  
  21. int main() {
  22.    int inputYear;
  23.    cin>>inputYear;
  24.    if(checkLeapYear(inputYear)){
  25.       cout<<inputYear<<" is a leap year."<<endl;
  26.    }
  27.    else{
  28.       cout<<inputYear<<" is not a leap year."<<endl;
  29.    }
  30.  
  31.    return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top