#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
int days=0,days1=0,days2=0,totaldays=0;
int main()
{
clrscr();
float d,m;
int y,a=0;
char month[10];
do
{
clrscr();
cout<<endl<<endl<<"================================================================================================================================================================";
cout<<endl<<endl<<endl<<'\t'<<'\t'<<'\t'<<"ENTER 1. to check how many days you have lived"<<endl;
cout<<endl<<endl<<'\t'<<'\t'<<'\t'<<"ENTER 2. to exit"<<endl<<endl<<endl;
cout<<"================================================================================================================================================================";
cout<<endl<<endl<<endl<<endl<<endl<<"ENTER CHOICE (1/2) : ";
cin>>a;
if(a==1)
{
clrscr();
cout<<endl<<endl<<"Enter BIRTHDATE : ";
cin>>d;
if(d>31)
{
cout<<endl<<endl<<"INVALID DATE";
getch();
exit(0);
}
cout<<endl<<"ENTER BIRTH MONTH : ";
cin>>m;
if(m==1)
strcpy(month,"JANUARY");
else if(m==2)
strcpy(month,"FEBRUARY");
else if(m==3)
strcpy(month,"MARCH");
else if(m==4)
strcpy(month,"APRIL");
else if(m==5)
strcpy(month,"MAY");
else if(m==6)
strcpy(month,"JUNE");
else if(m==7)
strcpy(month,"JULY");
else if(m==8)
strcpy(month,"AUGUST");
else if(m==9)
strcpy(month,"SEPTEMBER");
else if(m==10)
strcpy(month,"OCTOBER");
else if(m==11)
strcpy(month,"NOVEMBER");
else if(m==12)
strcpy(month,"DECEMBER");
else
{
cout<<endl<<endl<<"INVALID MONTH"<<endl;
getch();
exit(0);
}
cout<<endl<<"ENTER BIRTH YEAR : ";
cin>>y;
if(d>29&&m==2&&y%4==0)
{
cout<<endl<<endl<<"INVALID BIRTHDATE"<<endl;
cout<<endl<<endl<<"DATE EXCEEDS 29 and AS IT IS LEAP YEAR"<<endl;
getch();
exit(0);
}
else if(d>28&&m==2&&y%4!=0)
{
cout<<endl<<endl<<"INVALID BIRTHDATE"<<endl;
cout<<endl<<endl<<"DATE EXCEEDS 28 and AS IT IS NOT A LEAP YEAR"<<endl;
getch();
exit(0);
}
/*****************************************************************************************
*****************************************************************************************
PLACING THE POINTER AT THE END OF THE BIRTH YEAR
*****************************************************************************************
***************************************************************************************** */
if(m==1&&y%4==0)
days=366-d;
else
days=365-d;
if(strcmp(month,"FEBRUARY")==0&&y%4==0)
days=366-31-d;
else if(m==2)
days=365-31-d;
else if(m==3&&y%4==0)
days=366-31-29-d;
else if(m==3)
days=365-31-28-d;
else if(m==4&&y%4==0)
days=366-31-29-31-d;
else if(m==4)
days=365-31-28-31-d;
else if(m==5&&y%4==0)
days=366-31-29-31-30-d;
else if(m==5)
days=365-31-28-31-30-d;
else if(m==6&&y%4==0)
days=366-31-29-31-30-31-d;
else if(m==6)
days=365-31-28-31-30-31-d;
else if(m==7&&y%4==0)
days=366-31-29-31-30-31-30-d;
else if(m==7)
days=365-31-28-31-30-31-30-d;
else if(m==8&&y%4==0)
days=366-31-29-31-30-31-30-31-d;
else if(m==8)
days=365-31-28-31-30-31-30-31-d;
else if(m==9&&y%4==0)
days=366-31-29-31-30-31-30-31-31-d;
else if(m==9)
days=365-31-28-31-30-31-30-31-31-d;
else if(m==10&&y%4==0)
days=366-31-29-31-30-31-30-31-31-30-d;
else if(m==10)
days=365-31-28-31-30-31-30-31-31-30-d;
else if(m==11&y%4==0)
days=366-31-29-31-30-31-30-31-31-30-31-d;
else if(m==11)
days=365-31-28-31-30-31-30-31-31-30-31-d;
else if(m==12&&y%4==0)
days=366-31-29-31-30-31-30-31-31-30-31-30-d;
else if(m==12)
days=365-31-28-31-30-31-30-31-31-30-31-30-d;
cout<<endl<<endl<<"YOUR BIRTHDAY : "<<d<<"/"<<month<<"/"<<y;
cout<<endl<<endl;
float dd,mm;
int yy;
char month1[10];
cout<<endl<<endl<<"Enter TODAY'S DATE : ";
cin>>dd;
if(dd>31)
{
cout<<endl<<endl<<"INVALID DATE";
getch();
exit(0);
}
cout<<endl<<"ENTER MONTH : ";
cin>>mm;
if(mm==1)
strcpy(month1,"JANUARY");
else if(mm==2)
strcpy(month1,"FEBRUARY");
else if(mm==3)
strcpy(month1,"MARCH");
else if(mm==4)
strcpy(month1,"APRIL");
else if(mm==5)
strcpy(month1,"MAY");
else if(mm==6)
strcpy(month1,"JUNE");
else if(mm==7)
strcpy(month1,"JULY");
else if(mm==8)
strcpy(month1,"AUGUST");
else if(mm==9)
strcpy(month1,"SEPTEMBER");
else if(mm==10)
strcpy(month1,"OCTOBER");
else if(mm==11)
strcpy(month1,"NOVEMBER");
else if(mm==12)
strcpy(month1,"DECEMBER");
else
{
cout<<endl<<endl<<"INVALID MONTH"<<endl;
getch();
exit(0);
}
cout<<endl<<"ENTER YEAR : ";
cin>>yy;
if(dd>29&&mm==2&&yy%4==0)
{
cout<<endl<<endl<<"INVALID DATE"<<endl;
cout<<endl<<endl<<"DATE EXCEEDS 29 and AS IT IS LEAP YEAR"<<endl;
getch();
exit(0);
}
else if(dd>28&&mm==2&&yy%4!=0)
{
cout<<endl<<endl<<"INVALID DATE"<<endl;
cout<<endl<<endl<<"DATE EXCEEDS 28 and AS IT IS NOT A LEAP YEAR"<<endl;
getch();
exit(0);
}
if(mm==1&&yy%4==0)
days1=dd;
else
days1=dd;
if(strcmp(month1,"FEBRUARY")==0&&yy%4==0)
days1=31+dd;
else if(mm==2)
days1=31+dd;
else if(mm==3&&yy%4==0)
days1=31+29+dd;
else if(mm==3)
days1=31+28+dd;
else if(mm==4&&yy%4==0)
days1=31+29+31+dd;
else if(mm==4)
days1=31+28+31+dd;
else if(mm==5&&yy%4==0)
days1=31+29+31+30+dd;
else if(mm==5)
days1=31+28+31+30+dd;
else if(mm==6&&yy%4==0)
days1=31+29+31+30+31+dd;
else if(mm==6)
days1=31+28+31+30+31+dd;
else if(mm==7&&yy%4==0)
days1=31+29+31+30+31+30+dd;
else if(mm==7)
days1=31+28+31+30+31+30+dd;
else if(mm==8&&yy%4==0)
days1=31+29+31+30+31+30+31+dd;
else if(mm==8)
days1=31+28+31+30+31+30+31+dd;
else if(mm==9&&yy%4==0)
days1=31+29+31+30+31+30+31+31+dd;
else if(mm==9)
days1=31+28+31+30+31+30+31+31+dd;
else if(mm==10&&yy%4==0)
days1=31+29+31+30+31+30+31+31+30+dd;
else if(mm==10)
days1=31+28+31+30+31+30+31+31+30+dd;
else if(mm==11&yy%4==0)
days1=31+29+31+30+31+30+31+31+30+31+dd;
else if(mm==11)
days1=31+28+31+30+31+30+31+31+30+31+dd;
else if(mm==12&&yy%4==0)
days1=31+29+31+30+31+30+31+31+30+31+30+dd;
else if(mm==12)
days1=31+28+31+30+31+30+31+31+30+31+30+dd;
cout<<endl<<endl<<"TODAY's DATE : "<<dd<<"/"<<month1<<"/"<<yy<<endl;
/*****************************************************************************
*****************************************************************************
to check no of leap years
*****************************************************************************
*****************************************************************************/
int noofyears=((yy-1)-(y));
int leap;
if(noofyears%4==0)
leap=noofyears/4;
else if(noofyears%4!=0)
leap=noofyears/4+1;
days2=leap+(365*noofyears);
cout<<endl<<endl<<endl<<endl<<"YOUR AGE : "<<noofyears;
cout<<endl<<endl<<"NO OF LEAP YEARS : "<<leap;
totaldays=days+days2+days1;
cout<<endl<<endl<<"TOTAL DAYS YOU HAVE LIVED : "<<totaldays;
getch();
}
else if(a==2)
exit(0);
}while(a!=2);
}