c++ program for sum of two times - c program with parth patthar

c program with parth patthar

learn c and c++ in better way and with simple example.

Believe on your own logic

Saturday, November 24, 2018

c++ program for sum of two times

/*sum of two times */
#include<iostream.h>
#include<conio.h>
class time
{
int h,m;
public:
void get()
{
cout<<"enter h:";
cin>>h;
cout<<"\n enter miniute";
cin>>m;
}
void sum(time t1,time t2)
{
h=t1.h+t2.h;
m=t1.m+t2.m;
if(m>59)
{
h=h+1;
m=m-60;
}
cout<<h<<':'<<m;
}
};

int main()
{
clrscr();
time t1,t2;
t1.get();
t2.get();
t1.sum(t1,t2);
getch();
return(0);
}

No comments:

Post a Comment