Skip to content

Commit

Permalink
fixed betty
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenni-Foued committed Oct 30, 2020
1 parent b9834b9 commit bef87aa
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 88 deletions.
167 changes: 81 additions & 86 deletions print_hex.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,99 +6,94 @@
*/
int print_x(va_list arg)
{
int n = va_arg(arg, int);
unsigned int nb;
int tab[10];
int i, j, count = 0;
char a[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a', 'b', 'c', 'd', 'e', 'f'};
int b[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
if (n < 0)
{
_putchar('-');
count++;
nb = -n;
}
else
nb = n;
if (nb == 0)
{
_putchar('0');
count++;
return (count);
}
for (i = 0; nb != 0; i++)
{
tab[i] = nb % 16;
nb = nb / 16;
}
for (; i >= 0; i--)
{
for (j = 0; j < 17; j++)
{
if (tab[i] == b[j])
{
_putchar(a[j]);
count++;
break;
}
}
}
return (count);
}






int n = va_arg(arg, int);
unsigned int nb;
int tab[10];
int i, j, count = 0;
char a[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'a', 'b', 'c', 'd', 'e', 'f'};
int b[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};

if (n < 0)
{
_putchar('-');
count++;
nb = -n;
}
else
nb = n;
if (nb == 0)
{
_putchar('0');
count++;
return (count);
}
for (i = 0; nb != 0; i++)
{
tab[i] = nb % 16;
nb = nb / 16;
}
for (; i >= 0; i--)
{
for (j = 0; j < 17; j++)
{
if (tab[i] == b[j])
{
_putchar(a[j]);
count++;
break;
}
}
}
return (count);
}

#include "holberton.h"
/**
* print_X - print in hexadecimal function
*@arg: integer to convert
*Return: printed number
*/

int print_X(va_list arg)
{
int n = va_arg(arg, int);
unsigned int nb;
int tab[10];
int i, j, count = 0;
char a[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F'};
int b[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
if (n < 0)
{
_putchar('-');
count++;
nb = -n;
}
else
nb = n;
if (nb == 0)
{
_putchar('0');
count++;
return (count);
}
for (i = 0; nb != 0; i++)
{
tab[i] = nb % 16;
nb = nb / 16;
}
for (; i >= 0; i--)
{
for (j = 0; j < 17; j++)
{
if (tab[i] == b[j])
{
_putchar(a[j]);
count++;
break;
}
}
}
return (count);
int n = va_arg(arg, int);
unsigned int nb;
int tab[10];
int i, j, count = 0;
char a[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8',
'9', 'A', 'B', 'C', 'D', 'E', 'F'};
int b[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};

if (n < 0)
{
_putchar('-');
count++;
nb = -n;
}
else
nb = n;
if (nb == 0)
{
_putchar('0');
count++;
return (count);
}
for (i = 0; nb != 0; i++)
{
tab[i] = nb % 16;
nb = nb / 16;
}
for (; i >= 0; i--)
{
for (j = 0; j < 17; j++)
{
if (tab[i] == b[j])
{
_putchar(a[j]);
count++;
break;
}
}
}
return (count);
}
4 changes: 2 additions & 2 deletions print_r.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ int print_r(va_list arg)
i++;
i--;
for (; i >= 0; i--)
{
{
_putchar(str[i]);
counter++;
}
}
return (counter);
}

0 comments on commit bef87aa

Please sign in to comment.