#include<iostream.h>
#include<conio.h>
class
Age
{
int YY,MM,DD;
public:
void getdata();
void Add(Age,Age);
void display();
};
void
Age::getdata()
{
cout<<"\nEnter Age of
Person(DD.MM.YY):";
cin>>DD>>MM>>YY;
}
void
Add(Age a1,Age a2)
{
Age a;
a.MM=0;
a.DD=a1.DD+a2.DD;
if(a.DD>=30)
{
a.MM=a.DD/30;
a.DD=a.DD%30;
}
a.MM+=a1.MM+a2.MM;
if(a.MM>=12)
{
a.YY=a.MM/12;
a.MM=a.MM%12;
}
a.YY+=a1.YY+a2.YY;
a.display();
}
void
Age::display()
{
cout<<"\nAddition of Two date
is:\n";
cout<<"\t\t"<<"\nDD:"<<DD<<"\nMM:"<<MM<<"\nYY:"<<YY;
}
void
main()
{
clrscr();
Age a,b,c;
a.getdata();
b.getdata();
c=Add(a,b);
getch();
}
No comments:
Write comments