-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsample3.cpp
More file actions
63 lines (50 loc) · 723 Bytes
/
sample3.cpp
File metadata and controls
63 lines (50 loc) · 723 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Time{
private:
int h; int m; int s;
public:
Time(int r=0)
{
h=r; m=r; s=r;
}
void AddH(int n)
{
h= h + n;
h= h % 24;
}
void AddM(int n)
{
m= m + n;
h= h + m /60;
m= m % 60;
}
void AddS(int n)
{
s= s + n;
m= m + s / 60;
s= s % 60;
}
void Set(int n1, int n2, int n3);
void Show();
};
void Time::Set(int n1, int n2, int n3)
{
h=n1; m=n2; s=n3;
}
void Time::ShowSeconds()
{
int sum=0;
sum= h * 3600 + m * 60 + s;
printf("Total seconds= %d\n", sum );
}
void main()
{
int a=0;
Time t(2);
printf("Enter number:");
scanf("%d",a);
t.Set(a,30,12);
t.AddH(3);
t.AddM(a);
t.AddS(55);
t.ShowSeconds();
}