# C Program to ConvertDecimalnumber to Hexa Decimal  Number

## C Program to Convert Decimal numberinto Hexa Decimal Number

This page has a C Program to Convert Decimal number to Hexa Decimal Number. It is clear that, this C program will Convert the given Decimal number into Hexa Decimal Number. To convert decimal number into Hexa Decimal number, the program should divide the decimal number by 16 again and again till the number can be divided by 16 and the program should display (print) the remainders for each division on monitor screen (in reverse order) to form the Hexa Decimal equivalent. For Example: If the Decimal number 39 is given as input, the program will print the Hexa Decimal equivalent as 27.  The below given C program is used to Convert the given Decimal number into Hexa Decimal NumberKindly check out the program to Convert the given Decimal number into Hexa Decimal NumberThe Questions to Convert Decimal number into Hexa Decimal Number problem can be asked as . .

1). C Program to Convert Decimal number to Hexa Decimal Number.

2). C Program to Convert the given Decimal number into Hexa Decimal Number

3). C Program to find the Hexa Decimal equivalent of given Decimal number.

4). C Program to Print Hexa Decimal Equivalent of a Decimal Integer

5). Program to convert decimal to Hexa Decimal in c

### Number Program

#include<stdio.h>
#include<conio.h>
void decimal_to_hexa(long int);
int main(){
long int decimal;
clrscr();
printf("Enter an Integer decimal number : ");
scanf("%ld", &decimal);
printf("\n\n The given decimal number is : %ld", decimal);
decimal_to_hexa(decimal);
getch();
return(0);
}
void decimal_to_hexa(long int n){
long int a=1, i, remain[40];
printf("\n\n The Hexa Decimal number is : ");
while(n>0){
remain[a] = n % 16;
n = n / 16;
a++;
}
a--;
for(i=a;i>=1;i--){
if(remain[i]==10)
printf("A");
else
if(remain[i]==11)
printf("B");
else
if(remain[i]==12)
printf("C");
else
if(remain[i]==13)
printf("D");
else
if(remain[i]==14)
printf("E");
else
if(remain[i]==15)
printf("F");
else
printf("%ld", remain[i]);
}
}

Sample Output:

Enter an Integer decimal number : 45

The given decimal number is : 45

The Hexa Decimal number is : 2D

### Related Other Popular C Programs

*  Write a c program to check whether a given number is prime number or not?

*  Write a C program to find the prime numbers between 1 and 100

*  Write a C program to display the prime numbers between a range ?

*  Write a C program to find the prime numbers between a range using while loop?

*  Write a C program to find the sum of prime numbers between a range