-
-
Save jjn1056/d0d14d9644b5a6c67b75165c3cac0d97 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