In this video, we will learn how to convert a decimal number into hexadecimal. A decimal number system is a positional numeral system employing 10 as the base and requiring 10 different numerals, from 0 to 9. Whereas Hexadecimal numbers use 16 values to represent a number. Here, numbers from 0-9 are expressed by digits 0-9, and 10-15 are represented by characters from A–F.
Examples:
Input : 117
Output: 75
Input : 11
Output: B
Input : 34
Output: 22
Algorithm to Convert Decimal into Hexadecimal:
Step 1: Store the remainder when the number is divided by 16 in a temporary variable temp. If temp is less than 10, insert (48 + temp) in a character array otherwise if temp is greater than or equals to 10, insert (55 + temp) in the character array.
Step 2: Divide the number by 16 now.
Step 3: Repeat the above two steps until the number is not equal to 0.
Step 4: Print the array in reverse order now.
Program to Convert Decimal to Hexadecimal: https://www.geeksforgeeks.org/program-decimal-hexadecimal-conversion/