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.
Decimal To Hexadecimal Conversion
- Decimal – Hexadecimal
- 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; char hexadecimalnum[100]; //asking user to enter decimal value printf("Enter a Decimal Number: "); //reading user entered decimal value scanf("%ld", &decimalnum); quotient = decimalnum; //logc for converting decimal value to hexadecimal value while (quotient != 0) { remainder = quotient % 16; if (remainder < 10) hexadecimalnum[j++] = 48 + remainder; else hexadecimalnum[j++] = 55 + remainder; quotient = quotient / 16; } // displaying integer into character for (i = j; i >= 0; i--) printf("%c", hexadecimalnum[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
C PROGRAMMING EXAMPLES
- C Program to Convert Celsius to Fahrenheit
- C Program To Find Absolute Value
- Ternary Operator Program in C
- C Program For Addition Table Using For Loop
- Denomination Program in C
- C Program to Print Multiplication Table
- C Program Array with Example
- Binary Search in C Program Using Recursion
- Bubble Sort in C Using Pointers
- Bubble Sort Program in C Using Recursion
- Bubble Sort Program in C Using Array
- Bubble Sort Program in C Using Function
- Bubble Sort Program in C Using Linked List
- Stack Push Pop Program in C Using Arrays
- Factorial Program in C Using Pointers
- Factorial Program in C Using While Loop
- C Program For Factorial Using For Loop
- Factorial Program in C Using Recursion Function
- C Program To Reverse a String Using Pointers
- C Program To Swap Two Numbers Using Two Variables
Thanks a lot, it woks perfect!