r[i]=n1%16;

what is n1 ?
instead u can use it..
Code:
int main() 
{
char hx[256];
int decVal = 42;
sprintf(hx,"%x",decVal);
printf("Hex value of Decimal value %d  is %s\n",decVal,hx);
}

Last edited by asadullah.ansari; 17Mar2009 at 20:54..