#include <stdio.h>
#define BUFSIZE 8192
void input(const char *s, int *d) {
char buffer[BUFSIZE];
printf("%s",s);
fgets(buffer, sizeof(buffer), stdin);
sscanf(buffer,"%d",d);
}
int main(void) {
int month=0,year=0;
const int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
input("Enter month number, 1-12: ",&month);
input("Enter year number, 1-9999: ",&year);
printf("%d\n",days[month-1]+(
(month==2)&&(
(year%4==0)-(year%100==0)+(year%400==0)
)
));
return 0;
}
Comments
Leave a comment