#include bool is_leap_year(const int Y) { if (Y % 400 == 0) return true; if (Y % 100 == 0) return false; if (Y % 4 == 0) return true; return false; } int days_in_month(const int M, const int Y) { if (M == 1 || M == 3 || M == 5 || M == 7 || M == 8 || M == 10 || M == 12) return 31; if (M == 2) { if (is_leap_year(Y)) return 29; else return 28; } if (M == 4 || M == 6 || M == 9 || M == 11) return 30; cout << "M=" << M << " is invalid for days_in_month\n"; exit(1); } void test() { cout << "Enter month and year: "; const int month = read_int(); const int year = read_int(); cout << "There are " << days_in_month(month, year) << " days in that month\n"; test(); } int main() { test(); }