#include"stdio.h"
#include"conio.h"
#include
#include
#include
int month(int,int,int);
int yea(int);
void cal(int,int);
void print(int,int);
void main()
{
int g,year,h;
char ch,mu='y';
clrscr();
mos:
clrscr();
cout<<" INSTRUCTION FOR FINDING MONTH OF ANY YEAR";
cout<<"
ENTER MONTH IN LETTER AND YEAR ONWARDS 0000";
cout<<"
CALENDER";
printf("
PLEASE ENTER MONTH:=");
scanf("%d",&g);
printf("
NOW ENTER YEAR:=");
scanf("%d",&year);
printf("
FIND");
for(h=0;h<=3;h++)
{
printf(" .");
delay(100);
}
cal(g,year);
while(mu=='y')
{
ch=getch();
if(ch=='n')
{
if(g==12)
{
year+=1;
g=1;
cal(g,year);
}
g+=1;
cal(g,year);
}
else if(ch=='p')
{
if(g==1)
{
year-=1;
g=13;
cal(g,year);
}
g-=1;
cal(g,year);
}
else if(ch=='m')
{
year+=1;
cal(g,year);
}
else if(ch=='b')
{
year-=1;
cal(g,year);
}
else if(ch=='c')
goto mos;
else if(ch=='q')
{
exit(0);
}
}
fflush(stdin);
getch();
}
void cal(int g,int year)
{
int n,o,i;
clrscr();
cout<<"
TO FIND NEXT YEAR PRESS M";
cout<<"
TO FIND PREVIOUS YEAR PRESS B";
cout<<"
TO FIND NEXT MONTH PRESS N";
cout<<"
TO FIND PREVIOUS MONTH PRESS P";
cout<<"
TO EXIT PRESS Q";
printf("
MONTH %d",g);
printf("
YEAR %d",year);
n=yea(year);
o=month(g,year,n);
if((g==1)||(g==3)||(g==5)||(g==7)||(g==8)||(g==10)||(g==12))
{
print(31,o);
}
else if((g==4)||(g==6)||(g==9)||(g==11))
{
print(30,o);
}
else if(g==2)
{
if(year%4==0)
print(29,o);
else
print(28,o);
}
}
int yea(int year)
{
int i,k,n;
unsigned long int m,j;
for(i=0;i {
if(i%4==0)
{
m=m+366;
}
else
m=m+365;
}
j=m+7;
k=j%7;
n=k%7;
switch(n)
{
case 0:
n=1;
break;
case 1:
n=2;
break;
case 2:
n=3;
break;
case 3:
n=4;
break;
case 4:
n=5;
break;
case 5:
n=6;
break;
case 6:
n=0;
break;
}
return(n);
}
int month(int g,int year,int n)
{
int j,o;
for(j=1;j {
if((j==1)||(j==3)||(j==5)||(j==7)||(j==8)||(j==10))
n=n+31;
else if((j==4)||(j==6)||(j==9)||(j==11))
n=n+30;
else if(j==2)
{
if(year%4==0)
{
n=n+29;
continue;
}
else
n=n+28;
continue;
}
}
o=n%7;
return(o);
}
void print(int p,int q)
{
int i,j,l=0;
printf("
");
printf("MON TUE WED THU FRI SAT SUN
");
while(l!=q)
{
printf(" ");
l++;
}
for(i=1;i<=p;i++)
{
printf("%d ",i);
q++;
if(q==7)
{
printf("
");
q=0;
}
}
}