#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class date
{ private: char olddate[20];
int days;
public: char colddate[20];
int day;
void accp();
void getdate()
{ strcpy (colddate,olddate);
day=days;
return;
}
char newdate(char colddate[], int day);
void disp();
};
void main()
{ clrscr();
date d;
char a[20];int b;
d.accp();
strcpy(a,d.colddate);
b=d.day ;
d.newdate(a,b);
d.disp();
getch();
}
void date::accp()
{ cout<<"\n enter the old date (dd-mm-yyyy) : ";
gets(olddate);
cout<<"\n enter the numbers of days : ";
cin>>days;
}
char date::newdate(char colddate[], int day)
{ int m=0,y=0;char temp[20];
do
{ if (day>=360)
{ y++;
day=day-360;
}
else
if (day>=30)
{ m++;
day=day-30;
}
}while(day>=30);
colddate[0]=colddate[0]+(day/10);
colddate[1]=colddate[1]+(day%10);
colddate[3]=colddate[3]+(m/10);
colddate[4]=colddate[4]+(m%10);
colddate[8]=colddate[8]+(y/10);
colddate[8]=colddate[8]+(y%10);
return colddate[];
}
void date::disp()
{ cout<<"\n new date is "<<colddate;
}
0 comments:
Post a Comment