Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Forked from anonymous/001.cpp
Last active November 5, 2016 14:35
Show Gist options
  • Save jjn1056/d0d14d9644b5a6c67b75165c3cac0d97 to your computer and use it in GitHub Desktop.
Save jjn1056/d0d14d9644b5a6c67b75165c3cac0d97 to your computer and use it in GitHub Desktop.
//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