Created
November 5, 2016 14:26
-
-
Save anonymous/9445824a4c6d969660da26b7d1fcc46e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//C++ practice | |
#include<iostream> | |
#include<exception> | |
#include<stdexcept> | |
using namespace std; | |
int calcDays(int month, int year) | |
{ | |
int Days; | |
if (month == 4 || month == 6 || month == 9 || month == 11) Days = 30; | |
else if (month == 2) { | |
bool isLeapYear = (year % 4 == 0 && year % 100 !=0) || (year % 400 == 0); | |
if (isLeapyear) Days = 29; | |
else Days = 28; | |
} | |
else Days = 31; | |
return Days; | |
} | |
int main() | |
{ | |
int Days, month, year; | |
cout<<“Enter Month:”endl; | |
cin>>month; | |
cout<<“Enter year:”endl; | |
cin>>year; | |
calDays (Days); | |
cout<<Days<<“ “<<month<<“ “<<year<<endl; | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment