#include
#include
static char *months[]={"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"};
void main()
{
static int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long int ndays,ldays,tydays,tdays;
int d,i,m,fday,y;
char ch;
textcolor(LIGHTGREEN);
textbackground(LIGHTBLUE);
clrscr();
printf("Please Enter year(1900 onwards) & month(number):");
scanf("%d%d",&y,&m);
while(1)
{
ndays=(y-1)*365l;
ldays=(y-1)/4-(y-1)/100+(y-1)/400;
tdays=ndays+ldays;//total days
//check for the leap year
if((y%100==0 && y%400==0)||(y%4==0 && y%100!=0))
days[1]=29;
else
days[1]=28;
d=days[m-1];
tydays=0;
for(i=0;i<=m-2;i++)
tydays=tydays+days[i];
tdays=tydays+tdays;
fday=tdays%7;
cal(y,m,fday,d);
ch=getche();
switch(ch)
{
case 77:
if(m==12)
{
y++;
m=1;
}
else
m++;
break;
case 72:
y++;
continue;
case 75:
if(m==1)
{
y--;
m=12;
}
else
m--;
break;
case 80:
y--;
continue;
case 27:
exit(0);
}}}
cal(int yr,int mo,int fd,int da)
{
int i,r,c;
char a;
clrscr();
gotoxy(25,2);
printf("%s %d",months[mo-1],yr);
textcolor(LIGHTGREEN);
gotoxy(5,5);
printf("____________________________________________________");
gotoxy(10,6);
printf("MON TUE WED THU FRI SAT SUN");
gotoxy(5,7);
printf("____________________________________________________");
r=9;
c=11+(6*fd);
for(i=1;i<=da;i++)
{
gotoxy(c,r);
if(c==47)
textcolor(RED);
else
textcolor(LIGHTGREEN);
cprintf("%d",i);
if(c<=41)
c=c+6;
else
{
c=11;
r=r+1;
}
}
textcolor(LIGHTGREEN);
gotoxy(5,15);
printf("____________________________________________________");
gotoxy(11,17);
printf("UP-Next Year DOWN-Prev Year");
gotoxy(11,18);
printf("RIGHT-Next Month LEFT-Prev Month");
gotoxy(27,20);
printf("Esc-Exit");
return 0;
}
#include
static char *months[]={"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"};
void main()
{
static int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long int ndays,ldays,tydays,tdays;
int d,i,m,fday,y;
char ch;
textcolor(LIGHTGREEN);
textbackground(LIGHTBLUE);
clrscr();
printf("Please Enter year(1900 onwards) & month(number):");
scanf("%d%d",&y,&m);
while(1)
{
ndays=(y-1)*365l;
ldays=(y-1)/4-(y-1)/100+(y-1)/400;
tdays=ndays+ldays;//total days
//check for the leap year
if((y%100==0 && y%400==0)||(y%4==0 && y%100!=0))
days[1]=29;
else
days[1]=28;
d=days[m-1];
tydays=0;
for(i=0;i<=m-2;i++)
tydays=tydays+days[i];
tdays=tydays+tdays;
fday=tdays%7;
cal(y,m,fday,d);
ch=getche();
switch(ch)
{
case 77:
if(m==12)
{
y++;
m=1;
}
else
m++;
break;
case 72:
y++;
continue;
case 75:
if(m==1)
{
y--;
m=12;
}
else
m--;
break;
case 80:
y--;
continue;
case 27:
exit(0);
}}}
cal(int yr,int mo,int fd,int da)
{
int i,r,c;
char a;
clrscr();
gotoxy(25,2);
printf("%s %d",months[mo-1],yr);
textcolor(LIGHTGREEN);
gotoxy(5,5);
printf("____________________________________________________");
gotoxy(10,6);
printf("MON TUE WED THU FRI SAT SUN");
gotoxy(5,7);
printf("____________________________________________________");
r=9;
c=11+(6*fd);
for(i=1;i<=da;i++)
{
gotoxy(c,r);
if(c==47)
textcolor(RED);
else
textcolor(LIGHTGREEN);
cprintf("%d",i);
if(c<=41)
c=c+6;
else
{
c=11;
r=r+1;
}
}
textcolor(LIGHTGREEN);
gotoxy(5,15);
printf("____________________________________________________");
gotoxy(11,17);
printf("UP-Next Year DOWN-Prev Year");
gotoxy(11,18);
printf("RIGHT-Next Month LEFT-Prev Month");
gotoxy(27,20);
printf("Esc-Exit");
return 0;
}
No comments:
Post a Comment