Skip to content

Commit f9541c2

Browse files
committed
added: 7-print_last_digit.c, 8-24_hours.c
1 parent c9a0511 commit f9541c2

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
}
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
}

0x02-functions_nested_loops/main.h

+2
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ int _islower(int);
55
int _isalpha(int);
66
int print_sign(int);
77
int _abs(int);
8+
int print_last_digit(int);
9+
void jack_bauer(void);

0 commit comments

Comments
 (0)