Friday, September 14, 2007

Want to know your age in days....




DATE - DATE ===== ?????



Intro ::..

This program is built to find the difference between of days between the two given dates... The C language is used for its construction... This is the first program that i have tried out with a great grit... I thank my teacher since she is behind its thought...


Source Code ::..


/*PROGRAM TO FIND THE NUMBER DAYS BETWEEN TWO DATES*/


#include stdio.h

void main()
{
int x=0,d1,d2,m1,m2,y1,y2,t;
long int d=0,y=0;
clrscr();
printf("\n\n\n\n\n\tENTER THE FIRST DATE\n\n\t");
scanf("%d%d%d",&d1,&m1,&y1);
printf("\n\n\n\n\nENTER THE SECOND DATE\n\n\t");
scanf("%d%d%d",&d2,&m2,&y2);
if(y1>y2)
{
t=y1;
y1=y2;
y2=t;
t=m1;
m1=m2;
m2=t;
t=d1;
d1=d2;
d2=t;
}
if(y1==y2&&m1>m2)
{
t=m1;
m1=m2;
m2=t;
t=d1;
d1=d2;
d2=t;
}
if(m1<=7&&m1!=2) { if(m1%2==0) x=30; else x=31; } else if(m1>7)
{
if(m1%2==0)
x=31;
else
x=30;
}
else
{
if(y%4==0)
x=29;
else
x=28;
}
if(m1==m2&&y1==y2)
d=d2-d1;
else
{
d=x-d1;
d+=d2;
}
m1++;
while(m1=12&&y1!=y2)
{
m1=1;
y1++;
}
else
m1++;
}
d+=y;
printf("\nthe no of days between the two\ngiven dates are %ld\n",d);
getch();
}


Merits ::...

* I have tried out for almost all possible inputs and there are no exceptional cases...


Sample Output ::....




U can try this program by urself by clicking the link below.... Try this out its really interesting......


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

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


Look out ::..

By copying this code and placing it in your any of the C compilers you can exectute the program...


No comments: