You are on page 1of 2

#include<iostream.

h>

#include<conio.h>

void main()

int dd,mm,yy,odd,rd,rm,ry,oy1,oy2,day;

cout<<"Enter Date:";cin>>dd;

cout<<"Enter Month:";cin>>mm;

cout<<"Enter Full Year:";cin>>yy;

if(yy%400==0||(yy%4==0&&yy%100!=0))

odd=4;rd=29;

else

odd=3;rd=28;

rm=2;ry=yy-1;

oy1=ry-(ry%100);

odd=odd+(7-(2*(oy1%400))/100);

oy2=ry%100;

odd=odd+(oy2%7)+((oy2/4)%7);

odd=odd%7;

if(mm==1)

if(rd==29)

rd=4;

else

rd=3;

1
if(mm==3)

rd=0;

if(mm!=2&&mm%2==0)

rd=mm;

if(mm==5||mm==7)

rd=mm+4;

if(mm==9||mm==11)

rd=mm-4;

day=(odd+dd-rd)%7;

switch(day)

case 0:cout<<"Sunday";break;

case 1:cout<<"Monday";break;

case 2:cout<<"Tuesday";break;

case 3:cout<<"Wednesday";break;

case 4:cout<<"Thursday";break;

case 5:cout<<"Friday";break;

case 6:cout<<"Saturday";break;

getch();

Anish Prasannan

I year M.Tech CEN

Dear M.Tech students,

The above C ++ programme is written for the mental calculation method (calendar problem) that we learnt in the
class room. We appreciate Anish Prasannan for her efforts in coding this. Anish Prasannan is eager to know
whether there is any flaw in her programme. If you find any error in the above programme, please let Anish
Prasannan know the same. You are also encouraged to discuss the above C programme with your friends or Anish
Prasannan

CIR Aptitude Team

You might also like