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 4059034 commit 65bbb9fCopy full SHA for 65bbb9f
0x02-functions_nested_loops/7-print_last_digit.c
@@ -0,0 +1,22 @@
1
+#include "main.h"
2
+
3
+/**
4
+ * print_last_digit - prints the last digit of a number
5
+ * @n: the int to extract the last digit from
6
+ * Return: value of the last digit
7
+ */
8
+int print_last_digit(int n)
9
+{
10
+ int a;
11
12
+ if (n < 0)
13
+ n = -n;
14
15
+ a = n % 10;
16
17
+ if (a < 0)
18
+ a = -a;
19
+ _putchar(a + '0');
20
21
+ return (a);
22
+}
0x02-functions_nested_loops/main.h
@@ -5,3 +5,4 @@ int _islower(int c);
int _isalpha(int c);
int print_sign(int n);
int _abs(int);
+int print_last_digit(int);
0 commit comments