Translate

Saturday, December 28, 2013

Here is a c++ program for calender. where u can find any date up to year 32500

//C++ Program for Calender
.
# include <iostream.h>
# include <conio.h>
char *months[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
void cal(int yr,int mo,int fd,int da);
void main(){
int days[12]={31,28,31,30,31,30,31,31,30,31,30,31};
long int ndays,ldays,tdays,tydays;
int i,y,m,fday,d;
clrscr();
cout<<"Enter the YEAR & MONTH";
cin>>y>>m;
ndays=(y-1)*365l;
ldays=(y-1)/400-(y-1)/100+(y-1)/4;
tdays=ndays+ldays;
if(y%400==0&&y%1001==0||y%4==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=tdays+tydays;
fday=tdays%7;
cal(y,m,fday,d);
}
void cal(int yr,int mo,int fd,int da)
{
int i,r,c;
clrscr();
gotoxy(25,5);
cout<<months[mo-1]<<yr;
gotoxy(5,6);
cout<<"_________________________________________________________";
gotoxy(10,7);
cout<<"Mon Tue Wed Thur Fri Sat Sun";
gotoxy(5,8);
cout<<"_________________________________________________________";
r=10;
c=11+fd*6;
for(i=1;i<=da;i++){
gotoxy(c,r);
cout<<i;
if(c<=41)
c=c+6;
else
{
c=11;
r=r+1;
}
}
gotoxy(5,16);
cout<<"_________________________________________________________";
getch();
}