-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadding-time-structures.cpp
More file actions
37 lines (32 loc) · 939 Bytes
/
adding-time-structures.cpp
File metadata and controls
37 lines (32 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Adding time using structures
// Date: 2023-10-01
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
struct time{
int hours, minutes, second ;
};
struct time T1, T2, T3;
top:
system("cls");
cout<<"Enter first distance (hours - minutes - seconds): ";
cin>>T1.hours>>T1.minutes>>T1.second ;
cout<<"Enter second distance (hours - minutes - seconds): ";
cin>>T2.hours>>T2.minutes>>T2.second ;
cout<<"\ntotal distance is: "<<endl;
T3.hours = T1.hours + T2.hours;
T3.minutes = T1.minutes + T2.minutes ;
T3.second = T1.second + T2.second ;
if(T3.second >= 60)
{
T3.second -= 60;
T3.minutes++;
if(T3.minutes >= 60 )
{ T3.minutes -= 60; T3.hours++;}
}
cout<<"hours"<<'\t'<<"minutes"<<'\t'<<"seconds"<<endl;
cout<<T3.hours<<'\t'<<T3.minutes<<'\t'<<T3.second<<endl;
return 0;
}