File tree 2 files changed +47
-0
lines changed
0x04-more_functions_nested_loops
2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ #include "main.h"
2
+
3
+ /**
4
+ * printDigits - print numbers more than 2 digits.
5
+ *
6
+ * @n: number to be processed.
7
+ *
8
+ * Return: Nothing.
9
+ */
10
+ void printDigits (int n )
11
+ {
12
+ int singleDigit ;
13
+ int base = 10 ;
14
+
15
+ while (n >= base )
16
+ {
17
+ base = base * 10 ;
18
+ }
19
+ while (base != 1 )
20
+ {
21
+ singleDigit = (n % base ) / (base / 10 );
22
+ _putchar (singleDigit + '0' );
23
+ base = base / 10 ;
24
+ }
25
+ }
26
+
27
+ /**
28
+ * more_numbers - prints 10 times the numbers,
29
+ * from 0 to 14, followed by a new line.
30
+ *
31
+ * Return: Nothing.
32
+ */
33
+ void more_numbers (void )
34
+ {
35
+ int line ;
36
+ int counter ;
37
+
38
+ for (line = 0 ; line <= 9 ; line ++ )
39
+ {
40
+ for (counter = 0 ; counter <= 14 ; counter ++ )
41
+ {
42
+ printDigits (counter );
43
+ }
44
+ _putchar ('\n' );
45
+ }
46
+ }
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ int _isdigit(int);
4
4
int mul (int , int );
5
5
void print_numbers (void );
6
6
void print_most_numbers (void );
7
+ void more_numbers (void );
You can’t perform that action at this time.
0 commit comments