The leap year thing is troubling, eg 29-02-2009 is not a leap year but it still displays a day which it should not.
#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
int d=0,m=0,y=0,r1=0,r2=0,r3=0,r4=0,l=0;
cout<<"Enter day : ";
cin>>d;
cout<<endl;
cout<<"Enter Month : ";
cin>>m;
cout<<endl;
cout<<"Enter Year : ";
cin>>y;
cout<<endl;
{
if(m==10||m==1)
m=0;
else if(m==2||m==3||m==11)
m=3;
else if(m==4||m==7)
m=6;
else if(m==9||m==12)
m=5;
else if(m==5)
m=1;
else if(m==6)
m=4;
else if(m==8)
m=2;
}
if ( y % 4 == 0 || y % 400 == 0 )
{
r1=y-2000;
r2=r1/4;
r3=r1+6+d+m+r2;
r4=(r3%7)-1;
}
else
{
r1=y-2000;
r2=r1/4;
r3=r1+6+d+m+r2;
r4=(r3%7);
}
switch(r4)
{
case 0:printf("SUNDAY");break;
case 1:printf("MONDAY");break;
case 2:printf("TUESDAY");break;
case 3:printf("WEDNESDAY");break;
case 4:printf("THURSDAY");break;
case 5:printf("FRIDAY");break;
case 6:printf("SATURDAY");break;
default:printf("NOT VALID");break;
}
getche();
}