 # C Program To Convert Decimal To Hexadecimal

C Program To Convert Decimal To Hexadecimal. If you are looking for a C program to convert decimal number to hexadecimal number example, this C programming tutorial will help you to learn how to write a program for decimal to hexadecimal in C. Just go through this C programming example to learn about decimal to hexadecimal conversion.

## C Program To Convert Decimal To Hexadecimal

Learn how to write a c Program to convert decimal number to hexadecimal number. Writing decimal to hexadecimal conversion program in C can be done using various techniques but here in this program, we show how to write a c program for decimal to hexadecimal in a proper way. Happy coding.

### Decimal To Hexadecimal Conversion Examples

Here coding compiler will give you the decimal to hexadecimal conversion examples. A decimal number consists of base 10, i.e (0 to 9) and a hexadecimal number consists of base 16 or hex, i.e (0 to 9) to represent values zero to nine and (a, b, c, d, e, f) to represent values from ten to fifteen. Use this decimal to hexadecimal converter tool to convert numbers.

•      10       –   A
•     15      –    F
•    25      –    19
•    50     –     32
•    75     –     4B
•    99    –      63

Related Program: C Program to Convert Decimal to Binary

### C Program For Decimal To Hexadecimal Conversion Source Code

You can copy paste the below C Program For Decimal To Hexadecimal Conversion Using while loop, in c compiler to check how the source code work. Or write your own decimal to hexadecimal C Program with the help of this below c programming tutorial.

Source Code:

```/* C program to Convert Decimal to Hexadecimal - DecimalToHex.C */

#include <stdio.h>

int main()
{
//variable declaration
long decimalnum, quotient, remainder;
int i, j = 0;

//asking user to enter decimal value
printf("Enter a Decimal Number: ");
scanf("%ld", &decimalnum);

quotient = decimalnum;

//logc for converting decimal value to hexadecimal value
while (quotient != 0)
{
remainder = quotient % 16;
if (remainder < 10)
else
quotient = quotient / 16;
}

// displaying integer into character
for (i = j; i >= 0; i--)
return 0;
}

```

### C Program To Convert Decimal Number To Hexadecimal Number Output

After you compile and run the above c program to convert decimal number to hexadecimal number, your C compiler asks you to enter the decimal number to convert into a hexadecimal number. After you enter a decimal integer, the program will be executed and give output as a hexadecimal number.

Output:

Entered decimal number is = 75

It’s Hexadecimal equivalent number is = 4B

### 1 thought on “C Program To Convert Decimal To Hexadecimal”

1. Thanks a lot, it woks perfect!