diff --git a/0x04-more_functions_nested_loops/101-print_number.c b/0x04-more_functions_nested_loops/101-print_number.c new file mode 100755 index 0000000..fe104ce --- /dev/null +++ b/0x04-more_functions_nested_loops/101-print_number.c @@ -0,0 +1,26 @@ +#include "main.h" + +/** + * print_number - prints an integer + * @n: integer to be printed + */ +void print_number(int n) +{ + unsigned int n1; + + if (n < 0) + { + n1 = -n; + _putchar('-'); + } else + { + n1 = n; + } + + if (n1 / 10) + { + print_number(n1 / 10); + } + + _putchar((n1 % 10) + '0'); +}