Tuesday, November 6, 2007

U may know ur date of birth but ur day of birth !!!




DATE ----------->>> DAY



Intro ::..

This program is used to find the day of a any given date... This may be your birthday or the day u met your first spouse or anything else.... This program is created with the last program as a base...


Source Code ::...


/*PROGRAM TO FIND THE DAY OF ANY DATE*/


#include stdio.h
#include conio.h

void main()
{
int x,i,d1=1,d2,m1=1,m2,y1=1,y2;
long int d=0,y=0;
clrscr();
printf("\n\n\n\n\n\n\n\n\n\n\tENTER THE DATE\n\n\t");
scanf("%d%d%d",&d2,&m2,&y2);
if(m2>12d2>31(m2==2&&((y2%4==0&&d2>29)(y2%4!=0&&d2>28))))
printf("\n\n\tInvalid date");
else
{
if(m1==m2&&y1==y2)
d=d2-d1;
else
{
d=31-d1;
d+=d2;
}
m1++;
while(m1=12&&y1!=y2)
{
m1=1;
y1++;
}
else
m1++;
}
d+=y;
i=d%7;
printf("\n\n\tThe day corresponding to the given date is\n\n\t\t");
switch(i)
{
case 6:
printf("SATURDAY");
break;
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;
}
}
getch();
}


Merits ::..


* This program too has no exceptional cases...U can know even the day when Buddha was born if u know the date....


Sample Output ::...




U can try this out by yourself by clicking the link below..... Its really interesting.....


http://www.ziddu.com/download.php?uid=aayel5yparCgl5ats6yZlJyiZbCWlJWr5
http://www.ziddu.com/download.php?uid=ba2hlJurb7GbmZettayZlJyiZ7CWlJWp7

Look out ::...

This program can be run on any normal C compilers...