Thursday 15 March 2012

how convert decimal number to hexadecimal number

#include<stdio.h>
main()
{
int i=0,j,n,a[20],m;
char b[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
printf("enter the decimal number:");
scanf("%d",&n);
m=n;
while(n>0)
{
a[i]=n%16;
n=n/16;
i=i++;
}
printf("hexadecimal equal of %d is =",m);
for(j=i-1;j>=0;j--)
{
printf("%c",b[a[j]]);
}
}

No comments:

Post a Comment