Advertisement
Guest User

Azis Sofyan P

a guest
Oct 22nd, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //function will return total number of days
  5. int getNumberOfDays(int month, int year)
  6. {
  7. //leap year condition, if month is 2
  8. if( month == 2)
  9. {
  10. if((year%400==0) || (year%4==0 && year%100!=0))
  11. return 29;
  12. else
  13. return 28;
  14. }
  15. //months which has 31 days
  16. else if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8
  17. ||month == 10 || month==12)
  18. return 31;
  19. else
  20. return 30;
  21. }
  22.  
  23. //Main program
  24. int main()
  25. {
  26. int days=0;
  27.  
  28. days = getNumberOfDays(2, 2016);
  29.  
  30. cout<<endl<<"Number of Days : "<<days;
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement