Code for Program to convert decimal to hexadecimal in C Programming
#include<stdio.h>
#include<conio.h>
int i=0,bin[100];
void main()
{
int j=0;
int read(),destobin();
clrscr();
j=read();
destobin(j);
getch();
}
int read()
{
int num;
printf("\n PLEASE ENTER THE VALUE IN DECIMAL ( 0 - 15 ): ");
scanf("%d",&num);
return(num);
}
int destobin(int j)
{
for(i=0;j>0;i++)
{
bin[i]=j%16;
j=j/16;
}
i--;
printf("\nDECIMAL TO HEXADECIMAL CONVERSION IS \t");
for(;i>=j;i--)
{
if(bin[i]==10)
printf("A");
elseif(bin[i]==11)
printf("B");
elseif(bin[i]==12)
printf("C");
elseif(bin[i]==13)
printf("D");
elseif(bin[i]==14)
printf("E");
elseif(bin[i]==15)
printf("F");
else
printf("%d",bin[i]);
}
}