Write a program for a perpetual calendar
leap year
{ if(year % 4 = = 0 & amp; & amp Year% 100! = 0 | | Year %400==0)
Returns1;
Otherwise, return 0;
}
int days_month (int month,int year)
{
if(month = = 1 | | month = = 3 | | month = = 5 | | month = = 7 | | month = = 8 | | month = = 10 | | month = = 12)
Returns 31;
if(month = = 4 | | month = = 6 | | month = = 9 | | month = = 1 1)
Return to 30;
if(month = = 2 & amp; & leap (year) =1) returns 29;
Otherwise return to 28;
}
Int firstday(int month, int year)
{ int w;
W =( 1+2 * month +3* (month+1)/5+ year+year /4+ year /400/100)% 7+1;
Return w;
}
Master ()
{int i, j= 1, k= 1, a, b, month, year;
Printf ("\ nEnter year and month: \ n");
Scanf("%d%d ",& month & year);
B = day _ month (month, year);
A = the first day (month, year);
Printf ("Sunday Monday Tuesday Wednesday Thursday Fri Saturday \ n");
If (a==7)
{ for(I = 1; I < = b; i++)
{printf("%4d ",I);
if(i%7==0)
{ printf(" \ n ");
}
}
}
If (a! =7)
{ while(j & lt; =4*a)
{ printf(" ");
j++;
}
for(I = 1; I < = b; i++)
{printf("%4d ",I);
If (i==7*k-a)
{ printf(" \ n ");
k++;
}
}
}
getch();