You are on page 1of 1

/* NAME: DHRUV H RATHOD

ROll No: 57 SEM 1 ICA A


SUBJECT : FOP
Program:Write a program To convert Hexa To decimal.
*/

#include<stdio.h>
#include<conio.h>
void main()
{
void dec2hex(int);
int dec;
clrscr();
printf("Enter Positive Number: ");
scanf("%d",&dec);
dec2hex(dec);
getch();
}

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]);
}
}
/*
Input:
Enter Positive Number: 30

Output:
1E
*/