VOOZH about

URL: https://www.geeksforgeeks.org/c/c-program-for-decimal-to-hexadecimal-conversion/

⇱ C Program For Decimal to Hexadecimal Conversion - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C Program For Decimal to Hexadecimal Conversion

Last Updated : 2 Aug, 2022

 Here we will build a C Program For Decimal to Hexadecimal Conversion using 4 different approaches i.e.

  1. Using format specifier
  2. Using modulus division operator
  3. Without using the modulus division operator
  4. Using Functions

We will keep the same input in all the mentioned approaches and get an output accordingly.

Input: 

decimal number = 45

Output: 

hexadecimal number = 2D

Method 1: Using the format specifier %X


Output
Hexadecimal number is: 2D

Method 2: Using the modulus division operator


Output
Hexadecimal value is: 2D

Method 3: Without using modulus division


Output
Hexadecimal value is: 2D

Method 4: Using functions


Output
Hexadecimal value is: 2D
Comment