#include int days_per_month(int month,int year) { int days=0; switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = 31; break; case 4: case 6: case 9: case 11: days = 30; break; case 2: days = 28; if(year%4 == 0) days++; break; } return days; } int main(void) { int st_year, end_year,st_month, end_month, cur_year,cur_month,days; printf("Enter starting month: "); scanf("%d",&st_month); printf("Enter starting year: "); scanf("%d",&st_year); printf("Enter ending month: "); scanf("%d",&end_month); printf("Enter ending year: "); scanf("%d",&end_year); days=0; /* Starting year */ cur_month = st_month; while(cur_month<=12) { days += days_per_month(cur_month,st_year); cur_month++; } /* In between years excluding starting and ending years */ cur_year = st_year+1; while (cur_year <= end_year-1) { days = days + 365; if(cur_year%4 == 0) { days++; } cur_year++; } /* Last year */ cur_month = 1; while(cur_month<=end_month) { days += days_per_month(cur_month,end_year); cur_month++; } printf("Total number of days between %02d/%d and %02d/%d is %d\n",st_month,st_year,end_month,end_year,days); return 0; }