We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 23f1169 commit 12cb1e0Copy full SHA for 12cb1e0
0x06-pointers_arrays_strings/101-print_number.c
@@ -1,24 +1,25 @@
1
#include "main.h"
2
3
/**
4
- * print_number - prints an integer;
5
- * @n: integer to be printed;
6
- */
+ * print_number - Prints any integer with putchar
+ * @n: Number to prints
+ *
7
+ * Return: Nothing
8
+ */
9
void print_number(int n)
10
{
- unsigned int n1;
11
+ unsigned int x;
12
13
if (n < 0)
14
- n1 = -n;
15
_putchar('-');
- } else
16
- {
17
- n1 = n;
+ n *= -1;
18
}
19
20
- if (n1 / 10)
21
- print_number(n1 / 10);
+ x = n;
+
+ if (x / 10)
22
+ print_number(x / 10);
23
- _putchar((n1 % 10) + '0');
24
+ _putchar(x % 10 + '0');
25
0 commit comments