How can I convert decimal number 287 to hex by using loops? not using hex function
#include <stdio.h>
#include <string.h>
void ReverseDigits(char *arr)
{
int i = 0 , j = strlen(arr)-1;
while(i<j)
{
char temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
++i;
--j;
}
}
int main()
{
int d , r, i = 0, num;
printf("Enter a number: ");
scanf("%d", &d);
r = 16;
num = d;
char output[100];
while (d > 0)
{
int val = d % r;
if(val>=0 && val<=9)
output[i++] = (char)(val + '0');
else
output[i++] = (char)(val - 10 + 'A');
d = d/r;
}
output[i] = '\0';
ReverseDigits(output);
printf("The number %d in base %d is %s\n", num, r, output);
return 0;
}
====================================
SEE OUTPUT

Thanks, PLEASE COMMENT if there is any concern.
How can I convert decimal number 287 to hex by using loops? not using hex function