Friday, 15 November 2013

Program For Finding DAY For DATE

#include<stdio.h>
#include<conio.h>
void main()
{
int date,month,year,mcode,yel2dg,yef2dg,ycode=6,i,remain;
clrscr();
printf("enter the date(Format:27 02 1991):");
scanf("%d%d%d",&date,&month,&year);
if(month>0&&month<=12)
{
switch(month)
{
case 1:if(date>0&&date<=31)
    {mcode=0;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 2:if(yel2dg%4!=0&&date>0&&date<=28)
    {mcode=3;}
    else if(yel2dg%4==0&&date>0&&date<=29)
    {mcode=3;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 3:if(date>0&&date<=31)
    {mcode=3;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 4:if(date>0&&date<=30)
    {mcode=6;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 5:if(date>0&&date<=31)
    {mcode=1;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 6:if(date>0&&date<=30)
    {mcode=4;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 7:if(date>0&&date<=31)
    {mcode=6;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 8:if(date>0&&date<=31)
    {mcode=2;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 9:if(date>0&&date<=30)
    {mcode=5;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 10:if(date>0&&date<=31)
    {mcode=0;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 11:if(date>0&&date<=30)
    {mcode=3;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
case 12:if(date>0&&date<=31)
    {mcode=5;}
    else
    {printf("Enter The Valid Day");goto end;;}
    break;
}}
else
{printf("Enter The Valid MONTH");goto end;}
yel2dg=year%100;
yef2dg=year/100;
if(yef2dg==0)
{ycode=6;}
else{
for(i=1;i<=yef2dg;i++)
{
if(ycode==0)
{ycode=8;}
 ycode=ycode-2;
}}
remain=(date+yel2dg+(yel2dg/4)+mcode+ycode)%7;
printf("Remainder=%d\n",remain);
if(yel2dg%4==0&&month==1||month==2)
{
switch(remain)
{
case 1:printf("Sunday");break;
case 2:printf("Monday");break;
case 3:printf("Tuesday");break;
case 4:printf("Wednesday");break;
case 5:printf("Thursday");break;
case 6:printf("Friday");break;
case 0:printf("Saturday");break;
}}
else
{
switch(remain)
{
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;
}}
end:
getch();
}



OUTPUT:-
IF U HAVE DOUBT IN THIS:-
Mail Me:manikandang29892@gmail.com

No comments:

Post a Comment