-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
JennyHadir
committed
Oct 30, 2020
1 parent
638866e
commit 886220f
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include "holberton.h" | ||
/** | ||
* print_u - prints unsigned integer function | ||
*@arg: integer to print | ||
* Return: number of integer printed | ||
*/ | ||
int print_u(va_list arg) | ||
{ | ||
unsigned int ar = va_arg(arg, int); | ||
unsigned int count = 0, i = 0, ar2 = 0, j = 1; | ||
if (ar > 9) | ||
{ | ||
ar2 = ar; | ||
for (; ar2; i++) | ||
{ | ||
ar2 /= 10; | ||
} | ||
i--; | ||
for (j = 1; i; i--) | ||
j *= 10; | ||
for (i = 0; ar; i++) | ||
{ | ||
_putchar(((ar / j) % 10) + '0'); | ||
count++; | ||
ar %= j; | ||
j /= 10; | ||
} | ||
} | ||
else | ||
{ | ||
_putchar(ar + '0'); | ||
count++; | ||
} | ||
return (count); | ||
} |