File tree 3 files changed +69
-0
lines changed
0x02-functions_nested_loops
3 files changed +69
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * print_last_digit - prints the last digit of a number.
5
+ *
6
+ * @n: the number to be proccessed.
7
+ *
8
+ * Return: return the value of the last digit.
9
+ */
10
+ int print_last_digit (int n )
11
+ {
12
+ int r = _abs (n % 10 ) + 48 ;
13
+
14
+ _putchar (r );
15
+ return (r - 48 );
16
+ }
Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * jack_bauer - prints every minute of the day of Jack Bauer,
5
+ * Starting from 00:00 to 23:59.
6
+ *
7
+ * Return: return nothing.
8
+ */
9
+ void jack_bauer (void )
10
+ {
11
+ int hours = 48 ;
12
+ int hour = 48 ;
13
+ int minutes = 48 ;
14
+ int minute = 48 ;
15
+ int AmOrPm = 57 ;
16
+
17
+ while (hours <= 50 )
18
+ {
19
+ if (hours == 50 )
20
+ {
21
+ AmOrPm = 51 ;
22
+ }
23
+
24
+ while (hour <= AmOrPm )
25
+ {
26
+ while (minutes <= 53 )
27
+ {
28
+ while (minute <= 57 )
29
+ {
30
+ _putchar (hours );
31
+ _putchar (hour );
32
+ _putchar (':' );
33
+ _putchar (minutes );
34
+ _putchar (minute );
35
+ _putchar ('\n' );
36
+ minute ++ ;
37
+ }
38
+
39
+ minutes ++ ;
40
+ minute = 48 ;
41
+ }
42
+
43
+ hour ++ ;
44
+ minutes = minute = 48 ;
45
+ }
46
+
47
+ hours ++ ;
48
+ hour = minutes = minute = 48 ;
49
+
50
+ }
51
+ }
Original file line number Diff line number Diff line change @@ -5,3 +5,5 @@ int _islower(int);
5
5
int _isalpha (int );
6
6
int print_sign (int );
7
7
int _abs (int );
8
+ int print_last_digit (int );
9
+ void jack_bauer (void );
You can’t perform that action at this time.
0 commit comments