Slight modification to yr can give u the expected result
Code:
#include <stdio.h>

int main ()
{

int n,r[10],i = -1, j = 0 ;
printf("Enter the decimal number\n");
scanf("%d",&n);
while(n)
{
i++;
r[i]=n%16;
n=n/16;
}

for(j=i;j>=0;j--)
{
if(r[j]==10)
printf("A");
else if(r[j]==11)
printf("B");
else if(r[j]==12)
printf("C");
else if(r[j]==13)
printf("D");
else if(r[j]==14)
printf("E");
else if(r[j]==15)
printf("F");
else
printf("%d",r[j]);
}
printf("\n");

}
~

Last edited by shabbir; 6Jul2012 at 14:31.. Reason: Code blocks