Revision: 25537
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 1, 2010 16:39 by ideabrian
Initial Code
int days_in_month(int month) { const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; switch (month) { case 1: printf("January has %d days\n", days[month]); break; case 2: printf("February usually has %d days\n", days[month]); break; case 3: printf("March has %d days\n", days[month]); break; case 4: printf("April has %d days\n", days[month]); break; case 5: printf("May has %d days\n", days[month]); break; case 6: printf("June has %d days\n", days[month]); break; case 7: printf("July has %d days\n", days[month]); break; case 8: printf("August has %d days\n", days[month]); break; case 9: printf("September has %d days\n", days[month]); break; case 10: printf("October has %d days\n", days[month]); break; case 11: printf("November has %d days\n", days[month]); break; case 12: printf("December has %d days\n", days[month]); break; default: printf("Hmmm.. that month wasn't programmed in.\n"); break; } // end switch return days[month]; } // end days_in_month
Initial URL
Initial Description
Initial Title
function days in month
Initial Tags
Initial Language
C