Program:
#include<stdio.h>
void dec2hex(int);
int main()
{
int dec;
printf("Enter Positive Integer Number: ");
scanf("%d",&dec);
dec2hex(dec);
return 0;
}
void dec2hex(int m)
{
int i=0,j;
char hex[10],store[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while(m>0)
{
hex[i]=store[m%16];
m=m/16;
i++;
}
for(j=i-1;j>=0;j--)
{
printf("%c",hex[j]);
}
}
Output:
#include<stdio.h>
void dec2hex(int);
int main()
{
int dec;
printf("Enter Positive Integer Number: ");
scanf("%d",&dec);
dec2hex(dec);
return 0;
}
void dec2hex(int m)
{
int i=0,j;
char hex[10],store[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while(m>0)
{
hex[i]=store[m%16];
m=m/16;
i++;
}
for(j=i-1;j>=0;j--)
{
printf("%c",hex[j]);
}
}
Output:
No comments:
Post a Comment