Skip to content

Commit 65bbb9f

Browse files
committed
Task 7
1 parent 4059034 commit 65bbb9f

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ int _islower(int c);
55
int _isalpha(int c);
66
int print_sign(int n);
77
int _abs(int);
8+
int print_last_digit(int);

0 commit comments

Comments
 (0)