Friday, March 26, 2010

integer to hexa conversion

int integer = 123;

itox (int integer)
{
while (integer > 0)
{
int temp = integer %16;
if (temp < 0)
break;

itox (integer /16);

if (temp >= 0 && temp <= 9)
printf(“%d”, temp);
else if (temp >= 10 && temp <= 15)
printf(“%c”, ‘A’ + temp – 10);
else
;//nothing to do
}
}

No comments: