/*Author-Neelkant.S.patil,GMIT,Davangere*/
#include<stdio.h>
#include<conio.h>
void main()
{
int date,mon,star,year=0,i;
clrscr();
printf("\n\t\t\tWEL_COME\n\t\nYOU CAN GIVE THE DATE OF THE YEAR FROM 2010-2020 AND FIND WHICH WEAK IT IS??\nWARNING:THE ENTER DATE SHOULD BE IN THE CALENDAR\n");
printf("FORMAT:DD(1-31)\MM(1-12)\YEAR(4DIGITS)\n\n");
scanf("%d%d%d",&date,&mon,&year);
i=0;
if(year==2010)
{
if(mon==1)
star=(date+(4+i))%7;
else if(mon==2)
star=(date+i)%7;
else if(mon==3)
star=(date+3)%7;
else if(mon==4)
star=(date+(3+i))%7;
else if(mon==5)
star=(date+(5+i))%7;
else if(mon==6)
star=(date+(1-i))%7;
else if(mon==7)
star=(date+(3+i))%7;
else if(mon==8)
star=(date+6)%7;
else if(mon==9)
star=(date+(2+i))%7;
else if(mon==10)
star=(date+(4-i))%7;
else if(mon==11)
star=(date+i)%7;
else
star=(date+(2+i))%7;
}
else
{
if(year%4!=0)
{
while(year!=2020)
{
if(year%4==0)
{
i=(i+2);
}
else
i=(i+2);
if(mon==1)
{
star=(date+(4+i))%7;
break;
}
else if(mon==2)
{
star=(date+i)%7;
break;
}
else if(mon==3)
{
star=(date+(3-(i+1)))%7;
break;
}
else if(mon==4)
{
star=(date+(3+i))%7;
break;
}
else if(mon==5)
{
star=(date+(5+i))%7;
break;
}
else if(mon==6)
{
star=(date+(1-i))%7;
break;
}
else if(mon==7)
{
star=(date+(3+i))%7;
break;
}
else if(mon==8)
{
star=(date+(6-(i+5)))%7;
break;
}
else if(mon==9)
{
star=(date+(2+i))%7;
break;
}
else if(mon==10)
{
star=(date+(4-i))%7;
break;
}
else if(mon==11)
{
star=(date+i)%7;
break;
}
else
{
star=(date+(2+i))%7;
break;
}
year=year+1;
}
}
}
switch(star)
{
case 0:printf("SUNDAY\n");break;
case 1:printf("MONDAY\n");break;
case 2:printf("TUEDAY\n");break;
case 3:printf("WEDNESDAY\n");break;
case 4:printf("THURDAY\n");break;
case 5:printf("FRIDAY\n");break;
case 6:printf("SATURDAY\n");break;
}
getch();
}
No comments:
Post a Comment