Skip to content

Commit 204c958

Browse files
committed
prints the sign of a number.
1 parent 2af15da commit 204c958

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

0x02-functions_nested_loops/5-sign.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include "main.h"
2+
3+
/**
4+
* print_sign - Entr point
5+
* @n: carrier variable
6+
* Description: prints the sign of a number
7+
* Return: 1 if n>0, 0 if n == 0, -1 if n<0
8+
*/
9+
10+
int print_sign(int n)
11+
{
12+
if (n > 0)
13+
{
14+
_putchar('+');
15+
return (1);
16+
}
17+
else if (n < 0)
18+
{
19+
_putchar('-');
20+
return (-1);
21+
}
22+
_putchar('0');
23+
return (0);
24+
}

0 commit comments

Comments
 (0)