#include 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) { switch(cur_month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = days+31; break; case 4: case 6: case 9: case 11: days = days+30; break; case 2: days = days+28; if(st_year%4 == 0) days++; break; } 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) { switch(cur_month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days = days+31; break; case 4: case 6: case 9: case 11: days = days+30; break; case 2: days = days+28; if(end_year%4 == 0) days++; break; } 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; }