WAP TO ADD TWO TIME AND ADD THEM & DISPLAY THE TOTAL TIME
#include<conio.h>
#include<iostream.h>
class time
{
int hr,min;
public:
void set_time(int h,int m)
{
hr=h;
min=m;
}
void disp()
{
cout<<hr<<":"<<min;
}
void add(time,time);
};
void time::add(time t1,time t2)
{
hr=t1.hr+t2.hr;
min=t1.min+t2.min;
if(min>60)
{
hr+=1;
min-=60;
}
}
void main()
{
clrscr();
time t1,t2,t3;
t1.set_time(5,30);
t2.set_time(3,70);
t3.add(t1,t2);
t1.disp();
cout<<endl;
t2.disp();
cout<<endl;
t3.disp();
getch();
}

No comments:
Post a Comment