-
Notifications
You must be signed in to change notification settings - Fork 1
/
E3-2.c
115 lines (93 loc) · 2.32 KB
/
E3-2.c
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* FILENAME : E3-2.c
*
* DESCRIPTION :
* Asks for an ammount of seconds and prints the equivalent
* in hours, minutes and seconds.
*
* PUBLIC FUNCTIONS :
* int Section1( seconds )
* int Section2( seconds )
* int Section3( seconds )
* int Section4( seconds )
*
* NOTES :
* This program is the solution to the proposed exercise
* in the fourth week of the class 'Programación'
* (programming) of Burgos University.
*
* AUTHOR : Rodrigo Díaz START DATE : 1 Mar 2017
*
* CHANGES:
* 1.1 [01MAR2017] - Removed redundancy
* 1.0 [01MAR2017] - Initial release
*/
#include <stdio.h>
int Section1(int);
int Section2(int);
int Section3(int);
int Section4(int);
int Section2Hours(int);
int Section2Minutes(int);
int Section2Seconds(int);
int Section3Hours(int *);
int Section3Minutes(int *);
int Section3Seconds(int *);
void Section4Hours(int);
void Section4Minutes(int);
void Section4Seconds(int);
int main(){
int seconds;
printf("Insert seconds: ");
scanf("%d", &seconds);
Section1(seconds);
Section2(seconds);
Section3(seconds);
Section4(seconds);
return 0;
}
int Section1(int seconds){
printf("\n1.- %d hours, %d minutes and %d seconds",seconds/3600,seconds%3600/60,seconds%60);
return 0;
}
int Section2(int seconds){
printf("\n2.- %d hours, %d minutes and %d seconds", Section2Hours(seconds), Section2Minutes(seconds), Section2Seconds(seconds));
return 0;
}
int Section2Hours(int seconds){
return seconds/3600;
}
int Section2Minutes(int seconds){
return seconds%3600/60;
}
int Section2Seconds(int seconds){
return seconds%60;
}
int Section3(int seconds){
printf("\n3.- %d hours, %d minutes and %d seconds", Section3Hours(&seconds), Section3Minutes(&seconds), Section3Seconds(&seconds));
return 0;
}
int Section3Hours(int *seconds){
return *seconds/3600;
}
int Section3Minutes(int *seconds){
return *seconds%3600/60;
}
int Section3Seconds(int *seconds){
return *seconds%60;
}
int Section4(int seconds){
Section4Hours(seconds);
Section4Minutes(seconds);
Section4Seconds(seconds);
return 0;
}
void Section4Hours(int seconds){
printf("\n4.- %d hours, ", seconds/3600);
}
void Section4Minutes(int seconds){
printf("%d minutes and ", seconds%3600/60);
}
void Section4Seconds(int seconds){
printf("%d seconds\n", seconds%60);
}